Skip to main content

working with rsync for backup and copy

Posted in
Your rating: None Average: 5 (3 votes)

Working with rsync:

First, make sure your machine has it..

If not, install it from ports. It's in: Category net. Might as well update your ports tree if you haven't.

cd /usr/ports/net/rsync

make install && make clean

Basic command to test it. 

 

prompt% rsync -v -e ssh user@remote_server.com:~/testfile.txt newfile.txt
Password:   <-- prompted me for a password for that local user.
testfile.txt

sent 42 bytes  received 120 bytes  29.45 bytes/sec
total size is 23  speedup is 0.14
prompt%

 

 

How to use rsync to copy folders from main server to a backup machine?

You can use the following command to copy the content of a folder on the server to a backup directory on another computer:


 

rsync -e "ssh -p 18765" -aHz YOUR_SERVER_IP:/home/USERNAME/folder/ /home/LOCAL_USER/BACKUP/folder/

rsync -v -e "ssh -p 18765" -aHz user@192.168.1.10:/usr/home/user/folder/ /usr/home/user/folder/

 

Make sure you have the syntax right.. Including the "". Change -p 18765 to the ssh port you use. YOUR_SERVER_IP with the IP addr of your server, USERNAME with the username of the account you want to copy from, and LOCAL_USER/BACKUP/folder/ with the path on your computer where you want the home folder to be copied.

Note: Don't forget to add the trailing slashes after the folder names otherwise data can be lost!

happy rsync'n

Post new comment

The content of this field is kept private and will not be shown publicly.
CAPTCHA
If you math.. you're in..
4 + 1 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.