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

192.168.O.1 is a private default IP address for most of the networks. This address can be used by routers, modems, and other IoT devices such as webcams and DVRs.

Add new comment