rsync --delete is dangerous!

I hosed my entire home directory on this server last night with an incorrect rsync command. I tried syncing my svn repository to the server like this:

rsync -az -e ssh --delete /var/svn/repos/ servername:/home/username/

The problem is that I had an extra slash on the end of "/var/svn/repos/". Without the extra slash, it would create a directory called repos inside servername:/home/username and sync it with /var/svn/repos. With the slash, it syncs the contents of "/var/svn/repos" with the contents of servername:/home/username, thus causing all files in servername:/home/username to be deleted because of the --deleted command.

What I could have done instead is create a directory on the remote server called repos and then rsync like this (actually you don't need to create repos first):

rsync -az -e ssh --delete /var/svn/repos/ servername:/home/username/repos

Or I could have done this:

rsync -az -e ssh --delete /var/svn/repos servername:/home/username

The last command will create a directory called repos in servername:/home/username and it will sync it but not delete anything in servername:/home/username. Add a trailing slah to /var/svn/repos and it will!

Luckily I had a nightly backup of my entire home directory on my local server's external backup drive. I was worried because although I make these nightly backups I haven't actually inspected them in a while. Fortunately everything was intact.



Hi David,

I was wondering what's the best command that I should use if I want to syncronize a filesystem called /zsync to another filesystem in other server called /zsync?A suggestion would much appreciated.Thanks in advance.


Use the "-n print what will be done, but do nothing" switch, and stop wheening around !

-n, --dry-run
This makes rsync perform a trial run that doesn't make any changes (and produces mostly the same output as a real run). It is most commonly used in combination with the -v, --verbose and/or -i, --itemize-changes options to see what an rsync command is going to do before one actually runs it.

"It meant the foal was in distress. So, we decided to induce labor. But first we put her on a van and took her to the Rood and Riddle Equine Hospital in Lexington, about 20 minutes away.

"They were waiting with a cardiologist, Dr. Johanna Reimer; a surgeon, Dr. Rolf Embertson, and a neo natal internist, Dr. Bill Bernard. We brought our vet, Dr. Jim Becht, and out broodmare manager, Gary Bush, and his foaling crew. And, because Genuine Risk felt more comfortable with them, they were allowed to perform the delivery."

Labor was induced by an injection, which took 20 minutes to work. And only 15 minutes later, after months of suspense, Genuine Risk delivered her firstborn. His heartbeat straightened out moments after he arrived. They were kept at the clinic for several hours to take a nap, then went home by van.

"The definition of a live foal," Dan Rosenberg said, "is that he must be standing and nursing. This one arrived at 5:05 in the evening, he was standing at 6:30 and he was nursing at 8:10. It's a blessing."

Just try to specify ones substance can be as unimaginable. This clarity with your post is heavenly and that i may believe you're a master for this issue. High caliber alongside your agree license me to grab your present provide for keep adjusted by utilizing drawing closer blog entry. Much appreciated many alongside you ought to go on the pleasurable take care of business. dental marketing expert

I found your this post while searching for some related information on blog search...Its a good post..keep posting and update the information.

This post is very simple to read and appreciate without leaving any details out. Great work! You completed certain reliable points there. I did a search on the subject and found nearly all persons will agree with your blog.

Are Citation and Trust flow metrics really a necessary statistic?There was a time when SEO was at a nascent stage and primary metrics such as Google Page Rank mattered a lot in SEOToday, SEO has advanced far beyond the domain of Page Rank and as such, secondary metrics such as trust flow, domain authority, citation flow, etc., have taken over Google Page Rank in terms of importance as far as ranking in Google is concerned. high trust flow backlinks

Astounding .. Astonishing .. I'll bookmark your web journal and take the bolsters additionally… I'm upbeat to discover such a large number of valuable information here in the post, we require work out more methods in such manner, a debt of gratitude is in order for sharing. best plumbing

Amazing article! I need individuals to know exactly how great this data is in your article. It's intriguing, convincing substance. Your perspectives are much like my own concerning this subject. cloveris

Add new comment