In order to execute the rsync command without the need to provide a password, you will need to install the public key on the remote server. In other words, /home/tony/backup/ on the local system will be a mirror image of /path/to/remote/backups/ on the remote system. This will ensure that we don’t unnecessarily keep the backups that we deleted locally with the find command on the remote server. rsync -a -delete /home/tony/backup/ the –delete flag above. We can make a mirror image of our local backup directory and everything in it with the rsync command. The reason we want to do this is in case this system is compromised and/or you lose access to it. Next, it’s a good idea to take your local backup files and back them up to another system. Execute the monthly backup script the 1st of every month at 12:45 AM.Execute the weekly backup script every Monday at 12:30 AM.Execute the daily backup script everyday at 12:15 AM. In case you’re not familiar with cron syntax, this is what we’re doing: 15 0 * * * sh /home/tony/backup-daily.shģ0 0 * * 1 sh /home/tony/backup-weekly.shĤ5 0 1 * * sh /home/tony/backup-monthly.sh Open the cron editor with the crontab -e command and add the following while specifying the actual full path to your script files. You can create a cronjob to call the daily, weekly, and monthly backup scripts. The following tar command will create a compressed archive of the /var/tar -zcf /home/tony/backup/monthly/backup-$(date +%Y%m%d).tar.gz -C /var/ The following tar command will create a compressed archive of the /var/tar -zcf /home/tony/backup/weekly/backup-$(date +%Y%m%d).tar.gz -C /var/ The following tar command will create a compressed archive of the /var/tar -zcf /home/tony/backup/daily/backup-$(date +%Y%m%d).tar.gz -C /var/ To do this, we will use the tar, find, and rsync commands as well as cron to automate the task. In this tutorial, you will learn how to create daily, weekly, and monthly backups on Ubuntu/Debian with a script.
0 Comments
Leave a Reply. |