Created
October 30, 2015 19:01
-
-
Save xeor/027118572574d6196672 to your computer and use it in GitHub Desktop.
rsync backup with rules fule
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
RSYNC="/usr/bin/rsync" | |
mydir=$(cd $(dirname $0);pwd) | |
todir="/backup" | |
cat "${mydir}/rules" | grep ^[+-] | $RSYNC -v -azr -T "${mydir}/tmp" --include-from=- / server:${todir} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# To test, use "rsync -nvv -azr --include-from=include / /tmp/", will not copy anything | |
# Since we have "- *" at the end, we must include every folder to the folder we want to include.. | |
# Rules are read (logically) by rsync from the bottom and up. So if we have - * at the end, we should include | |
# all the directories above it.. Put / at the end of directories! | |
# - will exclude | |
# + will include | |
# ** means include everything AND subfolders.. Eg, + /etc/**, we will still need + /etc/. | |
# # Is comments :) | |
+ / | |
+ /Pictures/ | |
+ /Pictures/by_year/ | |
+ /Pictures/by_year/** | |
- * |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment