I had a previous question (deleted it) and I still don't understand why it is so hard to understand what I'm trying to ask, but I'll try once again and more clearly.
So I'm copying over several folders over from server A to server B, but the command for each copy process ('rsync') has to be executed from the command line, once for each folder.
So, to copy folder A to server X, I execute a rsync command and once it's done copying, I execute a new rsync command to copy over folder B to server X.
I've did a little research, that probably helps you answer my needs. But I'm looking for a way to write multiple commands at once, that fires one after another if the previous one is finished with his actions (thus finished copying).
Usually, multiple commands are separated on one line by ;
semicolons or &&
ampersands.
The difference between is that if the first/previous command fails with semicolons, it still continues. If the command produces an error and you had used ampersands, than it will stop.
Thus, I used semicolons in my process and let my computer going on overnight.. but it only executed the first command, even though I written several on one line separated with semicolons. So It should have executed all of them, one by one... So first: How do I correctly execute multiple commands and B, what is wrong with my command?
sudo rsync -v -v -r -h -t —progress /Volumes/My\ Book/Backups.backupdb/MbpScs-van-iSCS/2014-01-02-233653/SSDaeffer /Volumes/BackupMyBook/ViaMacbookMove/DitIsDeMap ;
sudo rsync -v -v -r -h -t —progress /Volumes/My\ Book/Backups.backupdb/MbpScs-van-iSCS/2014-01-09-152837/SSDaeffer /Volumes/BackupMyBook/ViaMacbookMove/DitIsDeMap ;
sudo rsync -v -v -r -h -t —progress /Volumes/My\ Book/Backups.backupdb/MbpScs-van-iSCS/2014-01-20-201229/SSDaeffer /Volumes/BackupMyBook/ViaMacbookMove/DitIsDeMap ;
sudo rsync -v -v -r -h -t —progress /Volumes/My\ Book/Backups.backupdb/MbpScs-van-iSCS/2014-02-21-130931/SSDaeffer /Volumes/BackupMyBook/ViaMacbookMove/DitIsDeMap ;
sudo rsync -v -v -r -h -t —progress /Volumes/My\ Book/Backups.backupdb/MbpScs-van-iSCS/2014-03-05-113353/SSDaeffer /Volumes/BackupMyBook/ViaMacbookMove/DitIsDeMap ;
sudo rsync -v -v -r -h -t —progress /Volumes/My\ Book/Backups.backupdb/MbpScs-van-iSCS/2014-03-19-162703/SSDaeffer /Volumes/BackupMyBook/ViaMacbookMove/DitIsDeMap ;
sudo rsync -v -v -r -h -t —progress /Volumes/My\ Book/Backups.backupdb/MbpScs-van-iSCS/2014-05-13-215016/SSDaeffer /Volumes/BackupMyBook/ViaMacbookMove/DitIsDeMap ;
sudo rsync -v -v -r -h -t —progress /Volumes/My\ Book/Backups.backupdb/MbpScs-van-iSCS/2014-06-01-231321/SSDaeffer /Volumes/BackupMyBook/ViaMacbookMove/DitIsDeMap
I separated them with breaks here for readability purposes. Normally it's one whole line
This usually goes by with a ;
semicolon character
sudo sh -c 'rsync ...; rsync ...; ...'
Also note that you could simplify your command a lot by making use offor
.sh -c
. As far assudo
is concerned, there's only one command,sh
, with the two arguments-c
and'rsync ...; rsync ...; ...'
. Thissh
is run as root, and thus will also run all thosersync
commands as root. Therefore thersync
commands will have full root permissions.