0% found this document useful (0 votes)
216 views

Automatic Backup From Ubuntu Server With Rsync

Two Ubuntu servers are set up for automatic backup using rsync. Server 1 (tendo-Srv) has data to backup, and Server 2 (tendo-backup) stores the backups. SSH keys are generated and copied to allow passwordless rsync access. A cron job is configured to run rsync daily at 8pm from Server 1 to the /backup directory on Server 2. Logs are saved to monitor the backups.

Uploaded by

Imam Purnawan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
216 views

Automatic Backup From Ubuntu Server With Rsync

Two Ubuntu servers are set up for automatic backup using rsync. Server 1 (tendo-Srv) has data to backup, and Server 2 (tendo-backup) stores the backups. SSH keys are generated and copied to allow passwordless rsync access. A cron job is configured to run rsync daily at 8pm from Server 1 to the /backup directory on Server 2. Logs are saved to monitor the backups.

Uploaded by

Imam Purnawan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Lazy Geek -:)

Automatic backup from Ubuntu Server with Rsync

Scenario:

2 Ubuntu Server: 1 is named as tendo-Srv with an ip address of 192.168.1.190, from which we want to take backup and 1 is named as tendo-backup with an
ip address of 192.168.1.177, on which we want to place our backup. But we want all this process automatic, at a defined time/ interval.

Generate the ssh key pair on tendo-Srv:

ssh-keygen

Copy the public key to the tendo-backup:

Follow
scp ~/.ssh/id_rsa.pub [email protected]:

Connect to the tendo-backup:

ssh [email protected]

Append the public key to authorized_keys:

cat id_rsa.pub >> ~/.ssh/authorized_keys

We got an error saying “~/.ssh/authorized_keys: No such file or directory” it means that there is no .ssh directory for this user (this user has never used ssh
before). Simply create an empty .ssh directory with 700 permissions:

mkdir ~/.ssh
chmod 700 ~/.ssh

Now,try to append the public key to authorized_keys once again:

cat id_rsa.pub >> ~/.ssh/authorized_keys

Remove the uploaded copy of authorized_keys:

rm id_rsa.pub
Follow
Edit the ssh server configuration:

sudo nano /etc/ssh/sshd_config

Make sure that public key authentication is enabled (it should be enabled by default), these entries must be set to yes also:

RSAAuthentication yes
PubkeyAuthentication yes

Reload the ssh configuration:

sudo service ssh reload

Create a directory,where we want to keep the backup on tendo-backup server and set a permission on it:

sudo mkdir /backup


sudo chown arbab:arbab /backup/

Disconnect from the tendo-backup:

exit

Try to connect to tendo-backup server again, and this time, it will not ask for the password

ssh [email protected]

Follow
Create a separate directory and file, where we want to keep the rsync log on tendo-Srv and set the permission on it as well:

sudo mkdir /rsynclog


sudo touch /rsynclog/rsynclog.log
sudo chmod 0777 /rsynclog/rsynclog.log

Now, copy the files from tendo-Srv to tendo-backup with Rsync:

rsync -e ssh --progress --partial --delete -avz --log-file=/rsynclog/rsynclog.log /data/ [email protected]:/backup

Where /data/ is a directory on local server(tendo-Srv) and /backup/ is directory on remote server(tendo-backup) & rsynclog.log is a log file at /rsynclog
location, where it will save the log every time after execute the command.

Check the log file:

cat /rsynclog/rsynclog.log

Check the backup on the tendo-backup server:

cd /backup/
ls

Edit the Cron file (Special thanks to Fernando Flores, to correct the syntax of this command):

sudo crontab -user arbab -e

Follow
We need to configure it in such a way that it automatically take the backup at 8 p.m. everyday:

00 20 * * * rsync -e ssh --progress --partial --delete -avz --log-file=/rsynclog/rsynclog.log /data/ [email protected]:/backup

Hope this will help you!

Please Remember me in your prayers!

Name (required)

Email (required)

Website

Comment (required)

Submit »

Rate this:

1 Vote

Share this:

 Twitter  Facebook 5  LinkedIn 1  Print  More

 Like
Be the first to like this.

Related

File Synchronization Between Two Public-Key Authentication in SecureCRT Part-1: Creation of Hard drive image
Ubuntu Servers using Unison using Clonezilla

Linux, Ubuntu automatic backup, Automatic backup from Ubuntu Server with Rsync, backup, backup server, backup with rsync, rsync, ssh server,
ubuntu backup

Follow
← Mikrotik as Gateway Configure Mikrotik DHCP to assign ip address to only authorized client(s) →

Blog at WordPress.com. The zBench Theme. ↑ Top

Follow

You might also like