I am currently running an rsync command to backup my specific folder.
Here is the command:
rsync -rtzv -e --exclude "generator/" --exclude "workspace/gallery/server/lib/personas_constants.php" /home/brandon/workspace/gallery /home/brandon/workspace/gallery2
The issue I am having is the --exclude is not excluding the specific files. It is the relative path to the files from where I am running the rsync command. The exclude does however work for the "generator/" directory.
Can someone shine some light on this for me?
The --exclude-from rsync option allows us to specify a file that contains a list of directories to be excluded. The file should be plaintext, so a simple . txt file will do. List one directory per line as you're compiling the list of directories that you want to exclude.
Rsync with --ignore-existing-files: We can also skip the already existing files on the destination. This can generally be used when we are performing backups using the –link-dest option, while continuing a backup run that got interrupted. So any files that do not exist on the destination will be copied over.
gitignore files happen to use a syntax compatible with rsync . @JesseGlick is right, rsync is not able to parse . gitignore files, see stackoverflow.com/a/50059607/99834 workround.
It turned out that it is the relative path from the folders that are being rsync'd with one another. Not from where you are running the rsync command.
--exclude "generator/" --exclude "server/lib/personas_constants.php" --exclude "server/lib/connect.php"
Fixed my issues.
The --exclude
argument takes a pattern, and file names that match that pattern are excluded - not the specific path to a file.
If you don't have any other files called personas_constants.php
, then --exclude personas_constants.php
should do the trick - otherwise you'll have to do something fiddly including --exclude-from
and moving some files around.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With