I made a script to, every 6 hours, copy a folder to a backup folder, then put them in /var/www/html/backup/
.
My command to copy the files was cp -vR ~/world ~/backups/Backup\ on\ $date/world
My desired result was for each backup to become a folder, and for one folder to be inside it, called world
, which is copied from my home folder.
Instead, my command kept the full path of the folder. This meant that the the folder structure of the backup ended up being:
Backup on 5-3-2019
↳ home
↳ elijahmc
↳ backups
↳ Backup on 5-3-2019
↳ world
To try to fix this, I changed the arguments from cp -vR
to cp -vr
, and this fixed the folder under /backups
, but not when I move it to a Zip.
To recap, I changed cp -vR
to cp -vr
and now have this directory structure:
Backup on 5-3-2019
↳ world
I now turn it into a zip like so:
rm -f ~/backup.zip
(remove original zip)
zip -r ~/backup.zip ~/backups/Backup\ on\ $date
(turn new backup into backup.zip
in root directory
mv -f ~/backup.zip /var/www/html/backup/
(move backup.zip
to web server)
Downloading backup.zip
from the Apache server, the file structure has the same issue as the original command:
Backup on 5-3-2019
↳ home
↳ elijahmc
↳ backups
↳ Backup on 5-3-2019
↳ world
Does anybody know how to fix this?