This page looks best with JavaScript enabled

Rsnapshot

 ·  ☕ 3 min read  ·  🤖 TED LZY

Background

Rsnapshot is a rsync based utility, as the name suggests, it can take the snapshot of the filesystem at the moment, the backup disk size is made up only with the size of filesystem and the differences between different snapshots.
The OS I was using is Linux CentOS then, simliar steps should be followed across different OS.
Follow the steps below to get the utility running and monitor the file generate after the set scheduled time.

Installation

How to backup local

1
apt-get install rsnapshot 

Run the following command to verify

1
2
3
4
5
6
rsnapshot configtest 
rsnapshot hourly 
rsnapshot du 
rsnapshot hourly 
rsnapshot du 
rsnapshot-diff hourly.0/ hourly.1/ 

Test the installations and manually run the back up

1
rsnapshot -t hourly

Use crontab to check automatically run rsnapshot

1
cat /etc/cron.d/rsnapshot 

How to backup remote

Enable SSH login without password in both servers (just for reference, the user account information may vary according to different users and systems)
1
2
3
4
su rtksd8
ssh-keygen -t rsa
ssh ted@172.25.22.10 mkdir -p .ssh
cat id_rsa.pub | ssh ted@172.25.22.10 'cat >> .ssh/authorized_keys' 
console prompt missing
1
ssh ted@172.25.22.10 "chmod 700 .ssh; chmod 640 .ssh/authorized_keys"
console prompt missing
Change configuration in ‘/etc/rsnapshot.conf’

Also uncomment the “cmd_ssh” line to allow to take remote backups over SSH.

1
cmd_ssh                /usr/bin/ssh

One more thing you need to edit is “ssh_args” variable. If you have changed the default SSH Port (22) to something else, you need to specify that port number of your remote backing up server.

1
ssh_args               -p 7851

Backup Remote Directories

1
backup          root@example.com:/home/              /data/backup/

Run the backup process automatically

Edit file rsnapshot
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
vi /etc/cron.d/rsnapshot

# This is a sample cron file for rsnapshot.
# The values used correspond to the examples in /etc/rsnapshot.conf.
# There you can also set the backup points and many other things.
#
# To activate this cron file you have to uncomment the lines below.
# Feel free to adapt it to your needs.

0 */12          * * *           root    /usr/bin/rsnapshot hourly
30 3    * * *           root    /usr/bin/rsnapshot daily
0  3    * * 1           root    /usr/bin/rsnapshot weekly
#30 2   1 * *           root    /usr/bin/rsnapshot monthly
Edit file rsnapshot.conf
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
vi /etc/rsnapshot.conf
# All snapshots will be stored under this root directory.
#
snapshot_root   /mnt/sdb1/backup2210/
#########################################
#           BACKUP INTERVALS            #
# Must be unique and in ascending order #
# i.e. hourly, daily, weekly, etc.      #
#########################################

retain          hourly  2
retain          daily   7
retain          weekly  2
#retain         monthly 3
# ssh has no args passed by default, but you can specify some here.
#
ssh_args        -p 22
### BACKUP POINTS / SCRIPTS ###
###############################

# LOCALHOST
#backup /home/backup/           localhost/
backup  root@172.25.22.10:/home/RTCN1912/               remote/
#backup /etc/           localhost/
#backup /usr/local/     localhost/

Reference

http://www.tecmint.com/rsnapshot-a-file-system-backup-utility-for-linux/

Share on

TED LZY
WRITTEN BY
TED LZY
Programmer