LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 10-14-2013, 03:37 AM   #1
alaios
Senior Member
 
Registered: Jan 2003
Location: Aachen
Distribution: Opensuse 11.2 (nice and steady)
Posts: 2,203

Rep: Reputation: 45
How rsync works


Hi all,
I would like to ask your help as I try to understand how rsync works.
I was syncing some files to an external hard disk ($MOUNTPOINT) with the following line (runs through crontab)


Code:
 rsync -rav -e ssh lka@server:/storage/disk1/ $MOUNTPOINT
I have found one day that the hard disk on the remote server lka@server:/storage/disk1/ was unmounted so the folder /storage/disk1 was showing an empty folder.

I then checked my files on my external hard disk ($MOUNTPOINT) and all the files were still there. I was expecting (and luckily that did not happen) rsync to sync the empty folder to the external hard disk ($MOUNTPOINT). Of course that would mean "deleting" the files ...

Can someone explain me why this did not happen?

I would like to thank you in advance for your reply

Regards
Alex
 
Old 10-14-2013, 04:12 AM   #2
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,804

Rep: Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306
there are a few options to rule how and when should rsync delete those files, see man page and --delete* options
(you are lucky because the default is to avoid deleting files)
 
1 members found this post helpful.
Old 10-14-2013, 04:13 AM   #3
zhjim
Senior Member
 
Registered: Oct 2004
Distribution: Debian Squeeze x86_64
Posts: 1,748
Blog Entries: 11

Rep: Reputation: 233Reputation: 233Reputation: 233
There is an option to rsync to also delete files (--delete). If that is not given rsync only copies files from source to destination. So if there are no source files nothing gets copied. There is also an option to reverse delete so files that are not on destination are deleted on the source side.

I'd just say you give the man page a read. Its quite long so maybe read it once for an overview and a second time for each option there is.
 
Old 10-14-2013, 05:03 AM   #4
JJJCR
Senior Member
 
Registered: Apr 2010
Posts: 2,149

Rep: Reputation: 449Reputation: 449Reputation: 449Reputation: 449Reputation: 449
check out this link: https://calomel.org/rsync_tips.html

from link above:
Quote:
Using rsync instead of copy (cp)

rsync -av /usbdisk/ /localdisk/
Quote:
Using rsync over ssh instead of scp
rsync -avz /usbdisk/ calomel@somemachine:/backups/

rsync -avz --del /usbdisk/ calomel@somemachine:/backups/
Quote:
Rsync recursive copy with parent directory name
rsync -avz /usbdisk calomel@somemachine:/backups/

rsync -avz /data1 /data2 calomel@somemachine:/backups/
Quote:
Rsync pull instead of push

rsync -avz calomel@somemachine:/backups/ /usbdisk/
Quote:
Pull multiple files with rsync
rsync -avz calomel@somemachine:/remote_machine/{file1,file2,file3} /local/disk/
Quote:
Rsync when remote files or directories contain spaces
rsync -av calomel@somemachine:'/I\ Hate\ Spaces/some\ File.avi' /current_dir/
Quote:
Execute remote shell command to rsync files
rsync -avR calomel@somemachine:'`find /data/video -name "*.[avi]"`' /download/
Quote:
Pull data from a remote machine to local server using ssh
rsync -avx --timeout=30 --delete-excluded backupuser@remote_machine:/stuff/data/ /BACKUP/remote_machine/

rsync -Ravx --timeout=30 --delete-excluded backupuser@remote_machine:/stuff/data/ /BACKUP/remote_machine/
Quote:
Incremental backups using rsync
rsync --backup --backup-dir=`date +%Y.%m.%d` -a /data/working/ /BACKUP/
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
rsync don't works with many files... ginoboy Slackware 13 06-24-2015 11:45 AM
Rsync password asked even after generating key (while ssh works passwordless) frsechet Linux - Server 46 02-06-2015 05:55 PM
[SOLVED] Tab completion works now on remote hosts using scp or rsync? jlinkels Linux - Software 0 08-07-2011 11:57 AM
[SOLVED] rsync works differently under tcsh than bash? Vanyel Linux - Software 2 09-01-2009 09:55 AM
rsync works in one direction, but not the other hroit Linux - Desktop 7 08-14-2007 12:20 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 07:18 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration