How to regularly clone a folder in Ubuntu.
After looking for backup solutions, I came to the conclusion that it can be quite easy to regularly clone a folder in Ubuntu. This is way the files are not compressed or altered in any way. It can be quite useful if you are running VMs and you need to have backups of them, but you also need the backups to be easily accessible if necessary.
This works regardless of the Ubuntu version you are running.
Depending on your permissions, you simply have to add a line in crontab. In my case, I had to “sudo” it.
Yet again, depending on your configuration:
crontab -e
or
sudo crontab -e
Then copy this line at the end
00 01 * * 6 sudo rsync -avu /SOURCE_FOLDER /DESTINATION_FOLDER
Here is a breakdown of what everything means:
00 01 * * 6
This is when the line should run. In my case, at 00 minutes, at 01 hours, each Saturday (night).
Here you can edit your own cron schedule expressions (https://crontab.guru/)
(sudo) rsync -avu
- a — archive files and directory while synchronizing
- v — verbose output
- u — do not copy the files from source to destination if destination files are newer
To check whether the scheduler is properly entered or not, simply do a:
crontab -l
or
sudo crontab -l
You should see the line you added at the end of the output.
by the author.