Thursday, June 11, 2020

rsync: Simple step to sync backup to remote server

The simple step:

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


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

Related Posts:

0 comments:

Post a Comment