Linux - GeneralThis 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.
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.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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.
Distribution: Kubuntu 14.04 (Dell Linux-preinstalled laptop + 2 other laptops)
Posts: 117
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:
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.
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;
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.
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?
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.
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.