How does rsync work?
I'm just looking into using rsync to do some backups here and I have a few questions.
1. Do both the server and the client need to have rsync installed?
2. Is it possible to use rsync in conjunction with regular ftp to access a remote server?
I think I'm just a little confused as to how rsync works at this point and I have the feeling i'm looking at it a bit like ftp, curl, or wget... but it seems a little different. Can someone iron this out in my muddy little mind?
rsync is a replacement for rcp, as far as I know you need rsync on both machines. You can't rsync to a ftp server unless that server has rsync. rsync can't directly communicate with a ftp daemon.
rsync: a great tool! Here's a short summary
"rsync" is a very handy command that I use all the time to back up my files to another computer on my home network. (Of course, you can back it up to the same local machine, on the same drive even, if you want.) Apparently it will check to see what part of which files have changed, and only transmit the changed portions.
I'm not sure if you need rsync on both the local and the remote machine, since I have the same setup on both machines. It shouldn't be too hard to install, though, so why not just install on both machines?
I ask my rsync command to transfer files via ssh. (Other options are FTP, rsync daemon, etc. Hmm, I guess that means you DON'T need rsync on the remote machine if you're transferring by ssh.) If I wanted to backup my files from the machine at 192.168.0.111 to my current machine, the rsync command I would use is:
rsync -ab --backup-dir=/my/local/trash/dir -e ssh 192.168.0.111:/source/dir/ /dest/dir/
You can replace the "192.168.0.111:" with "my_machine_name:" if you've got it defined in /etc/hosts, or of course you can omit it if you're backing up onto the same machine. Of course, the remote machine has to have the SSH daemon running. The "--backup-dir" option will move into the specified directory any files that would otherwise have been overwritten; you can then check this directory and delete it manually.
I learned this use of "rsync" from "Linux Server Hacks", a book by Rob Flickenger published by O'Reilly.
Just to add to what was said above I use it on my own system in cron to backup my /home on an hourly basis ;
rsync --delete-after -avH /home/ /mnt/backup/home > /var/log/backup.log
explanation is to sync the files /home and /mnt/backup/home, delete the files on the destination which no longer exist on the source and record the events in a log file.
Also use it over ssh to backup my internet server;
rsync -ave ssh --delete webserver:/var/www/ /home/user_name/www/
note here I have the address of webserver in /etc/hosts so it resolves automatically and rsync is installed on both systems and is issued from the destination terminal.
Ok so say I have the following setup:
A webserver with the ip address of 192.168.1.111 which has ssh access.
The machine I am on has the ip of 192.168.1.112 and I have access to a linux terminal.
So now what I want to do is connect to the webserver, download a file located in /home/user/public_html/1.txt
After 1.txt has been downloaded it should be deleted from the server. Once this is done I would like to be able to make changes to 1.txt and then upload it again back to the server. I realize I could just leave it on the server, but this is a small part of a complex script that I am working on and it is necessary to remove the file from the server. How can I do this?
A sample script that might get you going to launch from client A to connect to client B, copy the file back and then remove it:
If you are just wanting to edit files on the server then if you use kde I can recommend KBear as it gives sftp (ftp via ssh) and the login is automated once setup and you can then edit files on the server directly as well as examine files. If you are using the latest kde 3.3 you also use the command fish://webserver or previous versions will accept sft://webserver. This is the system I use on a daily basis. I only use rsync to backup the files on the server.
|All times are GMT -5. The time now is 01:26 AM.|