Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

rsync --exclude not excluding specific files [closed]

Tags:

linux

rsync

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?

like image 494
lockdown Avatar asked Jan 03 '12 23:01

lockdown


People also ask

How do I ignore files in rsync?

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.

Does rsync ignore existing files?

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.

Does rsync use Gitignore?

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.


2 Answers

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.

like image 128
lockdown Avatar answered Oct 12 '22 23:10

lockdown


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.

like image 34
Kristian Glass Avatar answered Oct 12 '22 22:10

Kristian Glass