Moxa UC-8410A-T-LX [53/86] Automating rsync backups

Moxa UC-8410A-T-LX [53/86] Automating rsync backups
UC-8410A Series Linux Software General Debian Package Usage
5-13
The rsync command can be used to back up data to the destination location with encryption. The following
example illustrates how to back up data from directory1 to directory2:
moxa@Moxa:~$ sudo rsync -avP /Directory1/ /Directory2/
-v, --verbose increase verbosity
-a, --archive archive mode; equals -rlptgoD (no -H,-A,-X)
-P --progress show progress during transfer
--partial keep partially transferred files
Using rsync for External Backups
rsync can be configured in several different ways for external backups, but we will go over the most practical
(also the easiest and most secure) method of tunneling rsync through SSH. Most servers and even many clients
already have SSH, and it can be used for your rsync backups. We will show you the process to get one Linux
machine to back up to another on a local network. The process would be exactly the same if one host was
somewhere on the Internet; just note that port 22 (or whatever port you have SSH configured on), would need
to be forwarded on any network equipment on the server’s side of things.
Other than installing SSH and rsync on the server, all that really needs to be done is to set up the repositories
on the server where you would like the files backed up, and make sure that SSH is locked down. Make sure the
user you plan on using has a complex password. You might also want to switch the port (default port is 22) that
SSH listens on for added security.
We will run the same command that we did for using rsync on a local computer, but include the necessary
additions for tunneling rsync through SSH to a server on my local network. For user “user” connecting to
“192.168.1.1” and using the same switches as above (-avP) we will run the following:
moxa@Moxa:~$ sudo rsync -avP -e ssh /Directory1/ user@192.168.1.1:/Directory2/
Automating rsync Backups
Cron can be used on Linux to automate the execution of commands, such as rsync. Using Cron, we can have
our Linux system run nightly backups, or however often you would like them to run.
To edit the cron table file for the user you are logged in as, run:
moxa@Moxa:~$ sudo crontab -e
You will need to be familiar with vi in order to edit this file. Type “I” for insert, and then begin editing the cron
table file.
Cron uses the following syntax: minute of the hour, hour of the day, day of the month, month of the year, day
of the week, command.
It can be a little confusing at first, so let me give you an example. The following command will run the rsync
command every night at 10 PM:
0 22 * * * rsync -avP /Directory1/ /Directory2/
The first “0” specifies the minute of the hour, and “22” specifies 10 PM. Since we want this command to run
daily, we will leave the rest of the fields with asterisks and then paste the rsync command.
NOTE
Click the following link for more information on iptables and rsync.
http://rsync.samba.org/

Содержание

Скачать