Rsync: Difference between revisions

From Edgar BV Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 31: Line 31:
To rsync to a remote machine:
To rsync to a remote machine:


rsync -a /src/dir/ -e ssh userid@destination.ip.or.server.name:/directory/
rsync -a /src/dir/ -e ssh userid@destination.ip.or.server.name:/directory


to sync from a remote machine:
to sync from a remote machine:


rsync -a -e ssh userid@src.ip.or.server.name:/directory/ /dst/dir/
rsync -a -e ssh userid@src.ip.or.server.name:/directory /dst/dir/


To copy a whole machine,  
To copy a whole machine,  


rsync -a -h --stats --exclude=/proc/ --exclude=/home/ --exclude=/sys/ -e ssh userid@src.ip.or.server.name:/directory/ /dst/dir/
rsync -a -h --stats --exclude=proc/ --exclude=home/ --exclude=/sys/ -e ssh userid@src.ip.or.server.name:/directory /dst/dir/




If rsync gives io / data stream type errors, make sure the computer on the other side has rsync, or it won't work.
If rsync gives io / data stream type errors, make sure the computer on the other side has rsync, or it won't work.


==================
</pre>
</pre>
run from 192.168.1.6 (192.168.1.8 was rsync server)
run from 192.168.1.6 (192.168.1.8 was rsync server)
Line 63: Line 61:
# rsync -a /home/sites/www.more-in.com/site/live/rsync_dir/usgpeoplenv/ -e ssh root@82.94.91.78:/home/sites/www.more-in.com/site/live/usgpeoplenv/
# rsync -a /home/sites/www.more-in.com/site/live/rsync_dir/usgpeoplenv/ -e ssh root@82.94.91.78:/home/sites/www.more-in.com/site/live/usgpeoplenv/
# password: xxxxxxx
# password: xxxxxxx
</pre>
= Notes =
When using rsync over ssh, make sure both machines have rsync installed or it won't work.
Take care of the "/"es  and the relative paths. Note in the following everything from 192.168.09:/home/ is copied into /mnt/home/ with the exclusion of /home/sites/www.maxq.nl/ and /home/sites/www.cmtportal.nl/site/zuilen/upload/. There are is no / before the path of the exclude and none after the destination dir.
<pre>
rsync -a -h --stats --exclude=sites/www.cmtportal.nl/site/zuilen/upload/ --exclude=sites/www.maxq.nl/ -e ssh root@192.168.0.9:/home /mnt/
</pre>
</pre>

Revision as of 10:38, 17 April 2013

rsync -a --stats /src/ /dst/

-a = -r (recursive), -l, -p (permissions), -t (times), -g, -o, -D

other usefull options:

-n = trial run
-h = human readable output
--progress (shows progression)
-i = itemised change list
-v = verbose
-vv = extra verbose
-u = update: only overwrite files with older mtimes

To use

--exclude-from=filename
filename has to be in the same directory as where the command is run and needs  the following lines

-------
- dir1/
- dir2/
----

which will exclude processing of /src/dir1/ and /src/dir2/

troubleshoot this with 
-vv

To rsync to a remote machine:

rsync -a /src/dir/ -e ssh userid@destination.ip.or.server.name:/directory

to sync from a remote machine:

rsync -a -e ssh userid@src.ip.or.server.name:/directory /dst/dir/

To copy a whole machine, 

rsync -a -h --stats --exclude=proc/ --exclude=home/ --exclude=/sys/ -e ssh userid@src.ip.or.server.name:/directory /dst/dir/


If rsync gives io / data stream type errors, make sure the computer on the other side has rsync, or it won't work.

run from 192.168.1.6 (192.168.1.8 was rsync server)

rsync -caRvuz --stats -e ssh --delete /usr/store/ razor@192.168.1.8:wipstore

run from 192.168.1.8 (192.168.1.6 was rsync server)

rsync -caRvuz --stats -e ssh root@192.168.1.6::wipstore /import/wipstore/


files /etc/rsyncd.conf


Rsync USG People NV
# rsync -a /home/sites/www.more-in.com/site/live/rsync_dir/usgpeoplenv/ -e ssh root@82.94.91.78:/home/sites/www.more-in.com/site/live/usgpeoplenv/
# password: xxxxxxx

Notes

When using rsync over ssh, make sure both machines have rsync installed or it won't work.

Take care of the "/"es and the relative paths. Note in the following everything from 192.168.09:/home/ is copied into /mnt/home/ with the exclusion of /home/sites/www.maxq.nl/ and /home/sites/www.cmtportal.nl/site/zuilen/upload/. There are is no / before the path of the exclude and none after the destination dir.

rsync -a -h --stats --exclude=sites/www.cmtportal.nl/site/zuilen/upload/ --exclude=sites/www.maxq.nl/ -e ssh root@192.168.0.9:/home /mnt/