1. Create a Local Backup of Your Data Using tar Command
# tar -zcvpf /[Backup_File_Location]/[Backup_Filename] /[User's_Home_Directory_Location] z : Compress the backup file with ‘gzip’ to make it small size. c : Create a new backup archive. v : verbosely list files which are processed. p : Preserves the permissions of the files put in the archive for later restoration. f : use archive file or device ARCHIVE.
2. Set up Passwordless SSH Authentication
Refer to this post : http://nothingos.blogspot.com/2020/06/ssh-passwordless-login-using-ssh-keygen.html
3. Create a Bash Script for Remote Backup Using rsync Command
#!/bin/bash
#Remote Server IP rserver=192.168.0.254
#Local backup location lbackuploc=/home/daygeek/Downloads/test/
#Remote backup location rbackuploc=/home/daygeek/site
#rsync command with standard port rsync -avz -e ssh $lbackuploc $rserver:$rbackuploc
#To delete files older than 10 days
find $rbackuploc/* -mtime +10 -exec rm {} \;
4. Automate a Backup Using crontab - Use the cronjob to schedule
0 8 * * * /opt/scripts/remote-backup-5.sh
0 comments:
Post a Comment