Rsync setup backup on CentOS / Debian / Ubuntu - brownforsoust77
In that respect are many ways to prepare accompaniment happening CentOS / Debian / Ubuntu servers – free utilities, mortal-written scripts using tar, bacula backup system, and overmuch more. Whol this in unmatchable way or another I have used or am using in my work.
Today I want to share with you my method acting of organizing a simple, convenient, and fast fashio to configure incremental substitute using the fashionable rsync utility on servers running CentOS / Debian / Ubuntu. The method works equally happening these systems, minor differences only in the rsync installation itself, which I will mention separately for each system.
Installment rsync on CentOS 6
Install xinetd to mechanically run rsync:
# yum install -y xinetd
We install rsync directly:
# yum install -y rsync
Redaction the rsync config for xinetd:
# mcedit /etc/xinetd.d/rsync
In the config we find the linedisable = yes and change it tono :
disenable = no
Running xinetd:
# /etc/init.d/xinetd start
And add it to the autorun:
# chkconfig xinetd on
Check if xinetd 873 listens happening the rsync port:
# netstat -lnpt | grep 873 tcp 0 0 0.0.0.0:873 0.0.0.0:* Mind 1431 / xinetd
All right, you can start configuring rsync.
We put rsync:
# yum install -y rsync
Adding to Auto Backup:
# systemctl enable rsyncd ln -s '/usr/lib/systemd/system/rsyncd.Service' '/etc/systemd/system/multi-user.target.wants/rsyncd.service'
Checking for Auto Backup:
# systemctl list-unit-files --type service | grep rsyncd rsyncd.service enabled
Run rsync:
# systemctl jump rsyncd
We check how information technology started:
# netstat -tulpn | grep rsync tcp 0 0 0.0.0.0:873 0.0.0.0:* Heed 2782 / rsync
Fine, you nates start configuring rsync.
Installation rsync along Debian / Ubuntu
Install rsync:
# pertinent-baffle install -y rsync
Config Dominate:
# mcedit / etc / default / rsync
Find the stringRSYNC_ENABLE = false and change it totrue :
RSYNC_ENABLE = true
Run rsync:
# /etc/init.d/rsync start [okay] Starting rsync daemon: rsync.
Check what whole works:
# netstat -tulpn | grep rsync tcp 0 0 0.0.0.0:873 0.0.0.0:* LISTEN 1767 / rsync
All right, you can start configuring rsync.
Configuring rsync
Now proceed to setup. The system of logic of our backups will follow the following. At the first start, we have a full backup of the info we are interested in in thecurrent brochure. So, once a Day, we tab the existing archive with the beginning and pull through up-to-date over again, overwriting all the denaturised files, merely do not delete them, but add them to theincrement folder, where day-to-day a leaflet with a name is created in the form of a date, files for the latest day.
Thus, we will always have a chockful archive, actual at the time of the last synchronizin, plus a set of folders for apiece sidereal day with files changed that day. How many days can be stored if necessary?
It turns out we birth such a picture:
Lashkar-e-Toiba's start to go through. Number one of all, configure rsync on the servers of information sources, from which we will collect data for championship.
Create the rsync contour file:
# mcedit /etc/rsyncd.conf
pelvic inflammatory disease file = /volt-ampere/consort/rsyncd.PID log lodge = /var/log/rsyncd.log transfer logging = real munge symlinks = yes # folder source for reliever [data] path = / data uid = root read lone = yes list = yes scuttlebutt = Information backup Dir auth users = backup secrets file = /etc/rsyncd.scrt
Create a register with the credentials for the connection:
# mcedit /etc/rsyncd.scrt
backup: 12345
where the backup is the username,12345 is the password.
We have register memory access only toroot, otherwise, rsync will not start:
# chmod 0600 /etc/rsyncd.scrt
After the configuration, restart rsync.
On Centos 6:
# /etc/init.d/xinetd re-start
On Centos 7:
systemctl restart rsyncd
On Debian / Ubuntu:
# /etc/init.d/rsync restart
Now attend the server receiver, which will store backup copies from the source servers. In that location we create an incremental backup book using rsync:
# mcedit /theme/bin/backup-server1.sh
#! / bank identification number / whap date # Folder, where we will put the archives syst_dir = / backup / # Name of the server that is archived srv_name = server1 # The address of the server that is archived srv_ip = 10.10.1.55 # The rsync drug user on the waiter that is archived srv_user = backup # Resource on the server for backup srv_dir = data echo "Kickoff backup $ {srv_name}" # Make a folder for incremental backups mkdir -p $ {syst_dir} $ {srv_name} / increment / # Run directly computer backup with parameters / usr / bin / rsync -a -delete -countersign-file = / etc / rsyncd.scrt $ {srv_user} @ $ {srv_ip} :: $ {srv_dir} $ {syst_dir} $ {srv_name} / contemporary / - -patronage --backup-dir = $ {syst_dir} $ {srv_name} / growth / `see +% Y-% m-% d` / # Clean folders with incremental archives older than 30 days / usr / bank identification number / find $ {syst_dir} $ {srv_name} / increment / -maxdepth 1 -type d -mtime +30 -EXEC rm -rf {} \; date echo "Clos backup man $ {srv_name}" We make the script feasible:
# chmod 0744 /beginning/bin/backup-server1.sh
Create a file in with a password for authorization along the source server:
# mcedit /etc/rsyncd.scrt
12345
We make read access only to root, otherwise, rsync wish return an error:
ERROR: parole file must not be other-accessible
Correct this:
# chmod 0600 /etc/rsyncd.scrt
That's it, now you can run the script and wait for IT to execute. It remains to add IT to the corn:
# mcedit / etc / crontab
30 23 * * * root word /root/bin/backing-server1.sh
I usually create different scripts for each waiter separately. So I coalesce their launch in one common script and I attention deficit disorder it to the cron. And then, arsenic necessary, I edit IT, add or cancel the server.
We specified in the settings logging to the file/var/log/rsyncd.backlog. Information technology is necessary to configure the revolution of this log so that it does not grow to infinity. On large file out servers, IT will grow real rapidly to hundreds of megabytes operating theater more.
To do this, create a data file with the rotation configuration in the/etc/logrotate.d folder:
# mcedit /etc/logrotate.d/rsyncd /var/log/rsyncd.log up { size = 500k compress rotate 4 missingok notifempty } With these settings, the rotation will occur every time the log file exceeds the 500 KB size. Testament be stored 4 versions of the log file. You can change these settings at your own discretion.
Example of backup server windows using rsync
Another exercise from my pattern. Let's say we ingest a windows server with some information, which we also want to back up. No job, it's done quite bu.
Create a network globe on the windows server with the information. Make a user and add it to access this booklet. This substance abuser we will use to connect the Windows to the Linux server.
Jump on the ball with the information that we will backup:
# mount -t cifs //192.168.0.16/docs / mnt / docs -o user = backup, password = 12345, iocharset = utf8, codepage = cp866
192.168.0.16 – the address of the
fill-in and 12345 – the user and countersign of the machine with access to the docs ball.
All, now the folder/mnt/docs can be used A a receiver in our backup script with rsync. If the folder is decorated right away to the server with backups, you need to configure it along the rsyncd server itself using the example of the source servers, run rsyncd on it, and specify 127.0.0.1 in the script every bit the IP address of the server.
In such cases I create several scripts: connected mounting balls, backup and unmounting, combine them into one, and run them sequentially. Atomic number 3 a leave, IT turns out that we link up the disk, piss a backup and turn IT off.
You have With success Subscribed!
Source: https://sprintally.com/rsync-setup-backup-on-centos-debian-ubuntu/
Posted by: brownforsoust77.blogspot.com

0 Response to "Rsync setup backup on CentOS / Debian / Ubuntu - brownforsoust77"
Post a Comment