Rsync

From AdminWiki

(Difference between revisions)
Jump to: navigation, search
m (Minimum working config)
Line 4: Line 4:
== cookbook ==
== cookbook ==
 +
 +
=== Basic functions ===
 +
 +
Rsync is a small program that behaves like rcp or scp does, but has many options like the remote-update protocol or included archiving methods to make the life easier. One of the main reasons why i use that GNU tool it the feature to copy links, devices, owners, groups and permissions in one easy step.
 +
 +
'''How could i keep two remote server directories synchronized without copying the whole directory every time? '''<br>
 +
Enable this one-liner in your [[crontab]] and it will only copy the new files to the remote server. Rsync will also update newer files, based on the access time from the [[filesystem]], with all permissions. To enable the secure transfer without a password for your [[cron]], you will have to generate a password-less [[ssh-key]].
 +
 +
<pre>
 +
rsync -avu --rsh="ssh -l <username>" <directory to sync> <username>@<remote host>:<remote directory>
 +
</pre>
 +
===Migrating a server===
===Migrating a server===

Revision as of 19:51, 31 May 2006

Contents

rsync

rsync is the perfect tool when you need to synchronize two files or file trees, be it just your homedirectory or a whole server. rsync can handle that.

cookbook

Basic functions

Rsync is a small program that behaves like rcp or scp does, but has many options like the remote-update protocol or included archiving methods to make the life easier. One of the main reasons why i use that GNU tool it the feature to copy links, devices, owners, groups and permissions in one easy step.

How could i keep two remote server directories synchronized without copying the whole directory every time?
Enable this one-liner in your crontab and it will only copy the new files to the remote server. Rsync will also update newer files, based on the access time from the filesystem, with all permissions. To enable the secure transfer without a password for your cron, you will have to generate a password-less ssh-key.

rsync -avu --rsh="ssh -l <username>" <directory to sync> <username>@<remote host>:<remote directory>


Migrating a server

To migrate a server,

rsync -aH --numeric-ids -x --delete / <additional mountpoints> <target>

usually does the trick. This should result in an exact copy of the source tree.

Minimum working config

log file = /var/log/rsyncd.log
use chroot = yes

[modulename]
path = /path/to/module
read only = yes
list = yes
transfer logging = yes 
Personal tools