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.

Tags: 

Comments

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.

Tarmizee

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.

http://yukthimachines.com/pages.asp?real-madrid-20132014-di-maria-third-... http://wingsind.com/pages.asp?italy-soccer-jersey-c-1_32 http://nyvdmag.com/cheap/index.php?201314-barcelona-2nd-away-cheap-thail... http://firstchatham.com/store/index.asp?camisetas-de-la-nasri-futbol-man... http://veliko-trojstvo.hr/store/index.asp?camisetas-fulham-20122013-prim... http://yukthimachines.com/pages.asp?olympique-lyonnais-jersey-c-5_17 http://fp-engineering.com/store/index.asp?sv-werder-bremen-catalog http://www.coolershoot.com/cheap/index.php?football_shirt_225935_Keeper_... http://richardgouldmd.com/store/index.cfm?portugal-shirt.html http://wingsind.com/pages.asp?real-madrid-jersey-c-7_23 http://www.coolershoot.com/cheap/index.php?product/adidas-acmilan_3.html http://true-golf.co.uk/shopping/index.asp?manchester-city-jersey-c-10_18 http://richardgouldmd.com/store/index.cfm?inter-milan-shirt.html http://richardgouldmd.com/store/index.cfm?borussia-dortmund-ramos-away-s... http://erstenplatz.com/store/index.asp?soccer-blog/how-to-deal-with-the-... http://rotekrieger.com/store/index.asp?team-gallery/ http://patcollinsastrology.com/cheap/index.php?soccer-cleats.html?dir=hu... http://richardgouldmd.com/store/index.cfm?liverpool-shirt-2014-15-away-g... http://patcollinsastrology.com/cheap/index.php?neymar-phantom-ag-boots-g... http://www.competitiveedge-strategies.com/cheap/index.php?products_new.html http://www.compasschattanooga.com/cheap/index.php?product/christiano-ron... http://patcollinsastrology.com/cheap/index.php?clubs-teams/english-teams... http://eres-dugalija.com/store/index.asp?mens-soccer-jerseys/ http://www.kromerco2.com/cheap/index.php?neymar-phantom-ag-boots-orange-... http://fp-engineering.com/store/index.asp?colombia-catalog http://richardgouldmd.com/store/index.cfm?netherlands-shirt-1.html http://www.compasschattanooga.com/cheap/index.php?product/michael-landon... http://midwaybuildingsupply.com/cheap/index.php?product-detail-id-2083/N... http://richardgouldmd.com/store/index.cfm?netherlands-robben-home-soccer... http://www.coolershoot.com/cheap/index.php?product/spanish-style-home-de... http://www.coolershoot.com/cheap/index.php?football_shirt_60393_MILAN_ex... http://yesesi.com/pages.asp?barcelona-home-jersey-20142015-p-1431.html http://eres-dugalija.com/store/index.asp?soccer-blog/historic-usa-victor... http://patcollinsastrology.com/cheap/index.php?clubs-teams/english-teams... http://www.competitiveedge-strategies.com/cheap/index.php?2014-world-cup... http://richardgouldmd.com/store/index.cfm?inter-milan-2014-15-andreolli-... http://www.condorgun.com/cheap/index.php?1314-chivas-away-thailand-socce... http://nyvdmag.com/cheap/index.php?1314-brazil-blue-polo-shirt-p-233.html http://www.compasschattanooga.com/cheap/index.php?football_shirt_57258_C... http://eres-dugalija.com/store/index.asp?soccer-blog/balancing-fun-with-... http://www.compasschattanooga.com/cheap/index.php?soccer-jerseys/new-log... http://oldskooltrackers.com/cheap/index.php?france-2014-2015-home-soccer... http://www.cosenzaassociates.com/cheap/index.php?product/ai-se-eu-te-peg... http://www.coolershoot.com/cheap/index.php?product/new-jersey-liverpool_... http://www.kromerco2.com/cheap/index.php?messi-vii-trx-fg-lea-soccer-cle... http://www.kromerco2.com/cheap/index.php?football-fashion.html?dir=asc&m... http://yesesi.com/pages.asp?tottenham-20132014-ls-home-soccer-jersey-p-9... http://veliko-trojstvo.hr/store/index.asp?camisetas-swansea-20142015-seg... http://www.hvsdoc.com/cheap/index.php?juventus-1415-goalkeeper-green-soc... http://yesesi.com/pages.asp?inter-milan-jersey-c-1_14

http://www.rootandlodge.com/images/mynewimg/2014-2015-lyon-away-football... http://www.funkreman.com/images/mynewimg/original-custom-bayern-munich-m... http://www.moxiemakery.com/images/mynewimg/tottenham-hotspur-defoe-away-... http://www.stanejagodic.com/images/mynewimg/mexico-2014-ls-home-green-so... http://www.lotustr.com/images/mynewimg/custom-order-everton-fc-osman-21-... http://www.clipandclaro.com/images/mynewimg/sale-wholesale-2014-2015-liv... http://www.rootandlodge.com/images/mynewimg/new-custom-2014-2015-bayern-... http://www.addoriccio.com/images/mynewimg/juventus-del-piero-home-white-... http://www.shelbyalws.com/images/mynewimg/shop-2014-2015-liverpool-away-... http://www.funkreman.com/images/mynewimg/shop-cheap-fiorentina-rossi-49-... http://www.clipandclaro.com/images/mynewimg/discount-wholesale-italy-201... http://www.leastcoins.com.com/images/mynewimg/argentina-2014-higuain-ls-... http://www.maisonbatlo.com/images/newimg/real-madrid-arbeloa-home-white-... http://www.leastcoins.com.com/images/mynewimg/spain-2014-a.iniesta-away-... http://www.clipandclaro.com/images/mynewimg/2014-2015-chelsea-cahill-24-... http://www.funkreman.com/images/mynewimg/arsenal-gervinho-27-season-2013... http://www.orbeustest.com/images/mynewimg/manchester-united-welbeck-ls-h... http://www.retrolapse.com/images/mynewimg/custom-cheap-manchester-united... http://www.maisonbatlo.com/images/newimg/manchester-united-2013-2014-amo... http://www.orbeustest.com/images/mynewimg/manchester-united-2013-2014-am... http://www.lotustr.com/images/mynewimg/2014-2015-psv-eindhoven-third-foo... http://www.retrolapse.com/images/mynewimg/wholesale-official-lyon-gomis-... http://www.muslimpets.com/images/mynewimg/manchester-united-wayne-rooney... http://www.frogcontrol.com/images/mynewimg/bayern-munich-gotze-third-blu... http://www.frogcontrol.com/images/mynewimg/borussia-dortmund-2013-2014-b... http://www.rednicholson.com/images/mynewimg/2014-2015-lyon-away-football... http://www.leastcoins.com.com/images/mynewimg/real-madrid-2013-2014-khed... http://www.yougametv.com/images/newimg/juventus-away-blue-jersey-2014-20... http://www.stanejagodic.com/images/mynewimg/roma-13-14-home-soccer-jerse... http://www.shelbyalws.com/images/mynewimg/order-custom-manchester-united... http://www.moxiemakery.com/images/mynewimg/chelsea-2013-2014-bertrand-th... http://www.stanejagodic.com/images/mynewimg/barcelona-alex-song-home-red... http://www.hbdjd.com/images/mynewimg/manchester-united-2013-2014-evra-aw... http://www.rednicholson.com/images/mynewimg/shop-custom-2014-2015-bayern... http://www.addoriccio.com/images/mynewimg/portugal-2014-ronaldo-home-soc... http://www.rootandlodge.com/images/mynewimg/marseille-nkoulou-3-season-2... http://www.funkreman.com/images/mynewimg/discount-liverpool-season-2013-... http://www.rednicholson.com/images/mynewimg/wholesale-real-valencia-seas... http://www.rednicholson.com/images/mynewimg/cheap-sale-2014-2015-lyon-ho... http://www.stanejagodic.com/images/mynewimg/inter-milan-away-white-jerse... http://www.hbdjd.com/images/mynewimg/tottenham-hotspur-soldado-home-whit... http://www.leastcoins.com.com/images/mynewimg/barcelona-home-jersey-2014... http://www.iranisotop.com/images/mynewimg/arsenal-miyaichi-home-red-jers... http://www.rootandlodge.com/images/mynewimg/authentic-cheap-2014-2015-li... http://www.hbdjd.com/images/mynewimg/chile-2014-e.vargas-away-soccer-jer... http://www.orbeustest.com/images/mynewimg/colombia-2014-valderrama-ls-aw... http://www.stanejagodic.com/images/mynewimg/chelsea-third-black-jersey-2... http://www.stanejagodic.com/images/mynewimg/arsenal-rosicky-home-red-jer... http://www.frogcontrol.com/images/mynewimg/chelsea-2013-2014-bertrand-ls... http://www.iranisotop.com/images/mynewimg/italy-2014-balotelli-ls-home-s...

http://www.organizevfx.com/images/mynewimg/buy-new-sporting-cp-rinaudo-2... http://www.rednicholson.com/images/mynewimg/shop-wholesale-2014-2015-mar... http://www.lotustr.com/images/mynewimg/buy-discount-arsenal-mertesacker-... http://www.retrolapse.com/images/mynewimg/custom-new-real-madrid-marcelo... http://www.rednicholson.com/images/mynewimg/authentic-wholesale-2014-201... http://www.frogcontrol.com/images/mynewimg/arsenal-debuchy-home-red-jers... http://www.maisonbatlo.com/images/newimg/borussia-dortmund-reus-home-yel... http://www.rednicholson.com/images/mynewimg/hot-dortmund-aubameyang-17-s... http://www.hbdjd.com/images/mynewimg/manchester-city-home-blue-jersey-20... http://www.stanejagodic.com/images/mynewimg/arsenal-ozil-away-yellow-jer... http://www.retrolapse.com/images/mynewimg/2014-2015-bayern-munich-buyten... http://www.shelbyalws.com/images/mynewimg/genuine-custom-2014-2015-real-... http://www.maisonbatlo.com/images/newimg/tottenham-2013-2014-dembele-ls-... http://www.moxiemakery.com/images/mynewimg/mexico-2014-o.peralta-ls-away... http://www.hbdjd.com/images/mynewimg/manchester-united-wayne-rooney-home... http://www.frogcontrol.com/images/mynewimg/liverpool-2013-2014-cissokho-... http://www.iranisotop.com/images/mynewimg/manchester-city-2013-2014-clic... http://www.rednicholson.com/images/mynewimg/official-ac-milan-de-sciglio... http://www.addoriccio.com/images/mynewimg/argentina-2014-messi-away-socc... http://www.iranisotop.com/images/mynewimg/barcelona-2013-2014-pinto-away... http://www.retrolapse.com/images/mynewimg/2014-2015-liverpool-away-goalk... http://www.lotustr.com/images/mynewimg/wholesale-real-inter-milan-ricky-... http://www.addoriccio.com/images/mynewimg/manchester-united-welbeck-ls-h... http://www.retrolapse.com/images/mynewimg/wholesale-hot-2014-2015-bayern... http://www.lotustr.com/images/mynewimg/custom-original-inter-milan-cambi... http://www.lotustr.com/images/mynewimg/order-liverpool-skrtel-37-season-... http://www.shelbyalws.com/images/mynewimg/hot-wholesale-real-madrid-f.co... http://www.hbdjd.com/images/mynewimg/netherlands-2014-v.-persie-home-soc... http://www.rednicholson.com/images/mynewimg/cheap-custom-2014-2015-ac-mi... http://www.maisonbatlo.com/images/newimg/manchester-united-young-home-re... http://www.muslimpets.com/images/mynewimg/juventus-home-white-black-jers... http://www.iranisotop.com/images/mynewimg/chelsea-benayoun-home-blue-jer... http://www.iranisotop.com/images/mynewimg/real-madrid-sergio-ramos-home-... http://www.lotustr.com/images/mynewimg/colombia-2014-escobar-away-footba... http://www.organizevfx.com/images/mynewimg/cheap-hot-2014-2015-lyon-dabo... http://www.frogcontrol.com/images/mynewimg/arsenal-cazorla-home-red-jers... http://www.stanejagodic.com/images/mynewimg/mexico-2014-ls-away-soccer-j... http://www.retrolapse.com/images/mynewimg/wholesale-order-manchester-uni... http://www.clipandclaro.com/images/mynewimg/original-custom-2014-2015-ly... http://www.yougametv.com/images/newimg/real-madrid-varane-away-jersey-20... http://www.rootandlodge.com/images/mynewimg/real-cheap-atletico-madrid-d... http://www.clipandclaro.com/images/mynewimg/wholesale-cheap-2014-2015-re... http://www.moxiemakery.com/images/mynewimg/real-madrid-luka-modric-ls-ho... http://www.yougametv.com/images/newimg/cameroon-2014-eto'o-home-soccer-jersey.jpg http://www.stanejagodic.com/images/mynewimg/real-madrid-karim-benzema-ls... http://www.organizevfx.com/images/mynewimg/genuine-monaco-j.moutinho-8-s... http://www.funkreman.com/images/mynewimg/wholesale-new-2014-2015-chelsea... http://www.rednicholson.com/images/mynewimg/shop-2014-2015-ac-milan-sapo... http://www.hbdjd.com/images/mynewimg/newcastle-united-2013-2014-cabaye-a... http://www.moxiemakery.com/images/mynewimg/portugal-2014-ronaldo-away-so...

http://www.fdlgroup.co.uk/profilesion.asp?louis-vuitton-website-game-onl... http://www.aiitech.com/contacte.asp?louis-vuitton-women/handbags/louis-v... http://www.aimsolution.com/crankcase.asp?louis-vuitton-men/bags.html?dir... http://www.sjtranslift.co.uk/production.asp?louis-vuitton-new-monogram-t... http://www.controlspecialists.co.uk/commerction.asp?louis-vuitton-40-107... http://www.fdlgroup.co.uk/profilesion.asp?Discount-louis-vuitton-wallets... http://www.aimsolution.com/crankcase.asp?louis-vuitton-men/belts.html?li... http://www.aimsolution.com/crankcase.asp?louis-vuitton-men/louis-vuitton... http://www.trm-limited.co.uk/scrap-metal.asp?louis-vuitton-mens/bags/lou... http://www.balajimoulds.com/codeofconduct.asp?louis-vuitton-men/luggage/... http://www.sjtranslift.co.uk/production.asp?louis-vuitton-online-retaile... http://www.aimsolution.com/crankcase.asp?louis-vuitton-men/louis-vuitton... http://www.balajimoulds.com/codeofconduct.asp?louis-vuitton-men/bags/lou... http://www.sjtranslift.co.uk/production.asp?louis-vuitton-retailers-us-c... http://www.stgeorgeglass.co.uk/sneak.asp?louis-vuitton-95050-ca-nhac-vie... http://www.controlspecialists.co.uk/commerction.asp?online/p_192.html http://www.bharatheartscans.org/feedback.asp?louis-vuitton-women/louis-v... http://www.stgeorgeglass.co.uk/sneak.asp?louis-vuitton-used-rv-trailers-... http://www.aiitech.com/contacte.asp?new-arrivals.html?limit=30 http://www.controlspecialists.co.uk/commerction.asp?louis-vuitton-ursula... http://www.bharatheartscans.org/feedback.asp?louis-vuitton-internship-re... http://www.balajimoulds.com/codeofconduct.asp?louis-vuitton-men/bags/lou... http://www.balajimoulds.com/codeofconduct.asp?new-arrivals/louis-vuitton... http://www.stgeorgeglass.co.uk/sneak.asp?louis-vuitton-quality-youth-ser... http://www.aimsolution.com/crankcase.asp?louis-vuitton-men/luggage/louis... http://www.controlspecialists.co.uk/commerction.asp?Louis-vuitton-handba... http://www.balajimoulds.com/codeofconduct.asp?louis-vuitton-women/louis-... http://www.bharatheartscans.org/feedback.asp?louis-vuitton-men/small-lea... http://www.controlspecialists.co.uk/commerction.asp?louis-vuitton-90210-... http://www.aiitech.com/contacte.asp?louis-vuitton-men/bags/louis-vuitton... http://www.aimsolution.com/crankcase.asp?louis-vuitton-layouts-online/ http://www.controlspecialists.co.uk/commerction.asp?louis-vuitton-qualit... http://www.aimsolution.com/crankcase.asp?louis-vuitton-women/small-leath... http://www.fdlgroup.co.uk/profilesion.asp?louis-vuitton-ursula-42520-son... http://www.fdlgroup.co.uk/profilesion.asp?louis-vuitton-jacket-2xl-headp... http://www.fdlgroup.co.uk/profilesion.asp?louis-vuitton-store-employee-p... http://www.fdlgroup.co.uk/profilesion.asp?louis-vuitton-outlet-store-in-us/ http://www.balajimoulds.com/codeofconduct.asp?louis-vuitton-women/luggag... http://www.stgeorgeglass.co.uk/sneak.asp?louis-vuitton-store-ya-facebook/ http://www.aiitech.com/contacte.asp?louis-vuitton-men/shoes/louis-vuitto... http://www.aimsolution.com/crankcase.asp?louis-vuitton-women/handbags/lo... http://www.controlspecialists.co.uk/commerction.asp?louis-vuitton-kids-m... http://www.aimsolution.com/crankcase.asp?louis-vuitton-women/small-leath... http://www.aimsolution.com/crankcase.asp?louis-vuitton-women/handbags/lo... http://www.balajimoulds.com/codeofconduct.asp?new-arrivals/louis-vuitton... http://www.stgeorgeglass.co.uk/sneak.asp?louis-vuitton-quality-wigs-huma... http://www.controlspecialists.co.uk/commerction.asp?louis-vuitton-denim-... http://www.bharatheartscans.org/feedback.asp?louis-vuitton-men/belts/lou... http://www.aimsolution.com/crankcase.asp?louis-vuitton-x-$15-white-elephant-gift-ideas/ http://www.controlspecialists.co.uk/commerction.asp?louis-vuitton-online...

Add new comment