On my Android phone, I have:
- A cron job to move files at 1:59am from /sdcard/WhatsApp/Media to /sdcard/wppmediabkp folder before WhatsApp backup at 2:00am:
mv -f /sdcard/WhatsApp/Media /sdcard/wppmediabkp
- A cron job to move files at 2:30am back (from /sdcard/wppmediabkp to /sdcard/WhatsApp/Media):
mv -f /sdcard/wppmediabkp /sdcard/WhatsApp/Media
- The "cron jobs" are tasks on "Tasks!" app (scheduling them with
00 59 1 ? * *
and00 30 2 ? * *
). The commands are tested in Termux app also.
Aim:
- To exclude Media folder from backup, but to also restore image "link" to chats (to do not download again).
On restoration of wppmediabkp folder to /sdcard/WhatsApp/Media:
- Sometimes it works well (it creates the /sdcard/WhatsApp/Media with all its contents). It happens when /sdcard/WhatsApp/Media folder does not exist. For me, it is the expected behavior.
- Sometimes it creates a subfolder (/sdcard/WhatsApp/Media/wppmediabkp). It happens when /sdcard/WhatsApp/Media folder exists. For me, it is the issue - I would like to restore original folder tree, merging its contents.
I think it was reduced to a Unix issue, because I can use all Unix basic commands.
How to solve it (to get Media folder back merging its contents) using mv
command?