The rsync command excludes files and folders of exclude from
- 2020-05-09 19:43:30
- OfStack
Let's say the initial command looks something like this
rsync -e 'ssh -p 30000' -avl --delete --stats --progress demo@123.45.67.890:/home/demo /backup/
1. Eliminate separate folders and files
To exclude the sources folder, we can add the '--exclude' option:
--exclude 'sources'
The order went like this:
rsync -e 'ssh -p 30000' -avl --delete --stats --progress --exclude 'sources' demo@123.45.67.890:/home/demo /backup/
To exclude the "database.txt" file in the "public_html" folder:
--exclude 'public_html/database.txt'
The order went like this:
rsync -e 'ssh -p 30000' -avl --delete --stats --progress --exclude 'sources' --exclude 'public_html/database.txt' demo@123.45.67.890:/home/demo /backup/
2. Use '-- exclude-from 'to exclude multiple folders and files
Create documents:
/home/backup/exclude.txt
Define folders and files to exclude
sources
public_html/database.*
downloads/test/*
After testing 1 like
folder
uploads
download/softs/
Use instructions:
--exclude-from '/home/backup/exclude.txt'
The final command is as follows:
rsync -e 'ssh -p 30000' -avl --delete --stats --progress --exclude-from '/home/backup/exclude.txt' demo@123.45.67.890:/home/demo /backup/
How does rsync synchronize the directory in the target path, not the files in the path, and only want to synchronize the directory
rsync -e 'ssh -p 30000' -avl --delete --stats --progress demo@123.45.67.890:/home/demo /backup/
1. Eliminate separate folders and files
To exclude the sources folder, we can add the '--exclude' option:
--exclude 'sources'
The order went like this:
rsync -e 'ssh -p 30000' -avl --delete --stats --progress --exclude 'sources' demo@123.45.67.890:/home/demo /backup/
To exclude the "database.txt" file in the "public_html" folder:
--exclude 'public_html/database.txt'
The order went like this:
rsync -e 'ssh -p 30000' -avl --delete --stats --progress --exclude 'sources' --exclude 'public_html/database.txt' demo@123.45.67.890:/home/demo /backup/
2. Use '-- exclude-from 'to exclude multiple folders and files
Create documents:
/home/backup/exclude.txt
Define folders and files to exclude
sources
public_html/database.*
downloads/test/*
After testing 1 like
folder
uploads
download/softs/
Use instructions:
--exclude-from '/home/backup/exclude.txt'
The final command is as follows:
rsync -e 'ssh -p 30000' -avl --delete --stats --progress --exclude-from '/home/backup/exclude.txt' demo@123.45.67.890:/home/demo /backup/
How does rsync synchronize the directory in the target path, not the files in the path, and only want to synchronize the directory
rsync -av --delete -f '+ */' -f '- *' SRC/ DEST/