Rsync command is great choice if you need to deploy large amount of files.
It will save your time transferring only needed files (actually file parts) to remote host.
But when deployment process is everyday practice on a remote host will be many files that were deleted from a source host.
How to delete files absent in the source? Rsync give you flexible solution to use.
Deletion options for rsync command are below:
In my case I was using:
--delete-before
with -n option to see the result before any changes will be done.
So my command is:
rsync -ruzn --exclude=diy/META-INF --exclude=diy/jsp/WEB-INF --delete-before --progress --rsync-path=/opt/csw/bin/rsync /home/kits-ndc/TeamCity/branches/perforce/shelve/sprintST/j2ee-apps/ --rsh ssh user@hostname:/export/home/kits-nds/atg/BQ/j2ee-apps/ > rsync.log
As you can see I was using --exclude to save important files which mostly were created by ATG DAS server.
After debug you can remove -n and enjoy your digital life :)
Cheers!
It will save your time transferring only needed files (actually file parts) to remote host.
But when deployment process is everyday practice on a remote host will be many files that were deleted from a source host.
How to delete files absent in the source? Rsync give you flexible solution to use.
Deletion options for rsync command are below:
--del/--delete_during Deletes files from the destination dir as they are copied (saves memory compared to --delete-before: --delete-before makes a separate scan to look for deleteables)
--delete Deletes files in the destination directory if they don't exist in the source directory.
--delete-before Delete files in the destination directory before coping file-with-same-name from source directory
--delete-during Delete files in the destination directory WHILE copying file-with-same-name from source directory
--delete-delay Mark deletes during transfer, but wait until transfer is complete
--delete-after Receiver deletes after transfer, not before...If some other part of the rsync moved extra files elsewhere, you'd want this instead of --delete-delay, because --delete-delay decides what its going to delete in the middle of transfer, whereas --delete-after checks the directory for files that should be deleted AFTER everything is finished.
--delete-excluded Deletes files from the destination directory that are explicitly excluded from transferring from the source directory.
In my case I was using:
--delete-before
with -n option to see the result before any changes will be done.
So my command is:
rsync -ruzn --exclude=diy/META-INF --exclude=diy/jsp/WEB-INF --delete-before --progress --rsync-path=/opt/csw/bin/rsync /home/kits-ndc/TeamCity/branches/perforce/shelve/sprintST/j2ee-apps/ --rsh ssh user@hostname:/export/home/kits-nds/atg/BQ/j2ee-apps/ > rsync.log
As you can see I was using --exclude to save important files which mostly were created by ATG DAS server.
After debug you can remove -n and enjoy your digital life :)
Cheers!