I installed gitlab with docker on ubuntu server14.04, and then the gitlab files set in docker are automatically backed up to /opt/backups every day. However, because the ordinary computer used is not a server server, the boss is worried that the hard disk is easy to break down, so he bought a U disk. Then prepare to back up the files in the /opt/backups directory to the U disk automatically every day. The U disk has been mounted under the /mnt/usb directory. Since I am a front-end worker, I don't know much about shell. Do you want to know how to do it?
Thank you!
Can write a script, convenient backup at any time
The first step is to write a script that can back up files to the U disk.
For example: backups.shtar cvzf /mnt/usb/$(date +%Y%m%d%H%M%S).tar.gz /opt/backups
The second step is to use cron to automatically execute the backup script.
$ sudo crontab -e
0 17 * * * /bin/bash /where/is/your/backups.sh #17: 00 Automatic Backup:
Or directly use crontab -e :#17 to perform backup automatically:
0 17 * * * tar cvzf /mnt/usb/$(date +%Y%m%d%H%M%S).tar.gz /opt/backups