|
CentOS Linux Server Installation , FAQ, Tips and Tricks |
CentOS Linux Backup |
|||||||||||||||||||||||||||
Backup Using Rsnapshot |
|||||||||||||||||||||||||||
|
In our scenario below, we have 2 severs, there are :
Server 1: Hostname: linuxbackup.example.local IP :192.168.10.47/255.255.255.0 GW:192.168.10.1 Function: Rsnapshots server , all the data will be stored here.
Hostname: linuxmail.example.local IP :192.168.10.48/255.255.255.0 GW:192.168.10.1 Function: Rsnapshots client, this a Mail server that run on iRedmail Step1: Configure hostname for both serversAt Server1, Rsnapshot server
Step 2:
Install the Rsnaphot
package via Dag
RPM Repository
At linuxbackup.example.local, first we need to install the Dag RPM Repository
Next, we install Rsnapshot via Dag RPM Repository
Step3: Create
|
|
yum install rsnapshot –y cd /root
ssh-keygen -t dsa
|
Next, c
|
ssh-copy-id -i ~/.ssh/id_dsa.pub linuxmail
root@linuxmail's password: |
Now try logging into the machine, with ssh command
|
|
Check the hostname you just login
|
|
|
|
Note:
if your remote /target server does not have .ssh, please
create a folder call .ssh under root home directory .
AT linuxbackup.example.local
|
cp /etc/rsnapshot.conf /etc/rsnapshot.conf.ori vim /etc/rsnapshot.conf |
Modify the following lines in /etc/rsnapshot.conf
Change the snapshot root directory. By changing this setting all backup (aka. snapshots) will be stored under this root directory.
| snapshot_root /backup/ |
Next, Let us uncomment this to enable remote ssh backups over rsync.
|
cmd_ssh /usr/bin/ssh ssh_args -p 22 |
Add in, this the backup location, we will dump our rsnapshot backup to /backup/linuxmail
|
backup
root@linuxmail.example.local:/vmail/ linuxmail/ backup root@linuxmail.example.local:/opt/iredapd/ linuxmail |
Note:
By performing above configuration. Our backup of linuxmail will be backup at the linuxbackup under /backup/X.Y/ linuxmail, you will see in detail later
X – is either hourly, daily or weekly
Y- is 0-n , the number we keep the copy
Commented or remove the following local backup
|
#backup /etc/passwd localhost/ #backup /home/foo/My Documents/ localhost/ |
At /etc/rsnapshot.conf change BACKUP INTERVALS, Must be unique and in ascending order
|
interval hourly 6 interval daily 0 interval weekly 0 |
we maintain 6 copies hourly, for example 0-6 hourly copies. Thus, in our linuxbackup server, you will see the following folders under /backup folder
|
drwxr-xr-x 3 root root 4096 May 6 15:00 hourly.0 drwxr-xr-x 3 root root 4096 May 6 14:00 hourly.1 drwxr-xr-x 3 root root 4096 May 6 13:00 hourly.2 drwxr-xr-x 3 root root 4096 May 6 12:00 hourly.3 drwxr-xr-x 3 root root 4096 May 6 11:00 hourly.4 drwxr-xr-x 3 root root 4096 May 6 10:00 hourly.5 .. .. |
AT linuxbackup.example.local
|
mkdir
/backup |
|
rsnapshot configtest Syntax OK |
TIPS: Please use <Tab> button when
configiure /etc/rsnapshot.conf else the application will complain
whitespace error
rsnapshot configtest
----------------------------------------------------------------------------
rsnapshot encountered an error! The program was invoked with these
options:
/usr/bin/rsnapshot
configtest
----------------------------------------------------------------------------
ERROR:
/etc/rsnapshot.conf on line 216:
ERROR:
backup root@linuxmail:/etc/ linuxmail/
ERROR:
---------------------------------------------------------------------
ERROR:
Errors were found in /etc/rsnapshot.conf,
ERROR:
rsnapshot can not continue. If you think an entry looks right, make
ERROR:
sure you don't have spaces where only tabs should be.
AT linuxbackup.example.local
Run a
manual test of rsnap if this work perfectly
|
/usr/bin/rsnapshot
hourly |
If you
have motile rsnapshot configuration files, specify the config file
location, for example
|
/usr/bin/rsnapshot –c /etc/rsnapshotServerA.conf
hourly |
AT linuxbackup.example.local
|
crontab
–e 0 * * *
* /usr/bin/rsnapshot hourly 30 23 *
* * /usr/bin/rsnapshot daily |
|
# ll /backup
total 56
drwxr-xr-x 3 root root 4096 May
5 19:58 daily.0
drwxr-xr-x 3 root root 4096 May
6 15:00 hourly.0
drwxr-xr-x 3 root root 4096 May
6 14:00 hourly.1
drwxr-xr-x 3 root root 4096 May
6 13:00 hourly.2
drwxr-xr-x 3 root root 4096 May
6 12:00 hourly.3
drwxr-xr-x 3 root root 4096 May
6 11:00 hourly.4
drwxr-xr-x 3 root root 4096 May
6 10:00 hourly.5 |
(Taking
iRedmail as example)
Scenario, one of the user email mailbox was corrupted.
At linuxmail. example.local, Stop all mail activities and services
|
Service postfix stop Service dovecot stop Service httpd stop |
Backup the usermail box to another location
|
mkdir /mailboxbck mv /var/vmail/vmail1/example.cal/w/ww/www /mailboxbck |
For
example I want restore my mailbox at hourly.3 user name www to
192.168.10.48
|
scp -rp
/backup/hourly.3/linuxmail/var/vmail/vmail1/example.cal/w/ww/www/
root@192.168.10.48:/var/vmail/vmail1/example.cal/w/ww/
|
At
linuxmail. example.local
|
chown
vmail.vmail –R /var/vmail/vmail1/example.cal/w/ww/ service postfix start service dovecot start service httpd start
|
Finally
|
tail –f /var/log/maillog |
Now, you can check if your
Like this guide? Why not buy me a coffee?
|
Knowledge shared by 2010 1A-CentOSserver.com. Please feel free to link All trademarks are the property of their respective owners. Contact Us | Terms of Use | Privacy Policy |