Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place. |
| Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
03-05-2005, 07:36 PM
|
#1
|
|
LQ Newbie
Registered: Feb 2005
Posts: 28
Rep:
|
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?
Many thanks,
Stuart
|
|
|
|
03-05-2005, 09:06 PM
|
#2
|
|
Guru
Registered: Jan 2001
Posts: 24,128
Rep: 
|
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.
|
|
|
|
03-06-2005, 12:50 AM
|
#3
|
|
Member
Registered: Jan 2004
Distribution: Kubuntu 10.04 (Dell Linux-preinstalled laptop + a desktop); Maemo 5 (N900 phone computer)
Posts: 116
Rep:
|
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.
|
|
|
|
03-06-2005, 03:42 AM
|
#4
|
|
Senior Member
Registered: Jan 2003
Location: Devon, UK
Distribution: Debian Etc/kernel 2.6.18-4K7
Posts: 2,380
Rep:
|
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.
|
|
|
|
03-06-2005, 04:21 PM
|
#5
|
|
LQ Newbie
Registered: Feb 2005
Posts: 28
Original Poster
Rep:
|
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?
|
|
|
|
03-06-2005, 05:14 PM
|
#6
|
|
Guru
Registered: Jan 2001
Posts: 24,128
Rep: 
|
Quote:
Originally posted by obelxi
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?
|
Write a script that uses ssh and scp.. since your only copying 1 file, scp will do the job. rsync is better when using multiple files and such...
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:
Code:
#!/bin/bash
cd /path/you/want/to/place/your/remote/file
scp user@machineB:/home/user/public_html/1.txt .
sleep1
for machine in <your-remote-machine>
do
ssh $machine rm /home/user/public_html/1.txt
done
You'll want to add some echo's in there to tell what's going on and such. And you'll probably want to make it so it uses ssh keys so it doesn't prompt for your password for each step. man ssh and scp for more details.
|
|
|
|
03-07-2005, 01:49 AM
|
#7
|
|
Senior Member
Registered: Jan 2003
Location: Devon, UK
Distribution: Debian Etc/kernel 2.6.18-4K7
Posts: 2,380
Rep:
|
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.
|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 11:23 AM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|