2011-07-24 107 views
0

我似乎無法得到命令備份/ etc/php5,/ etc/apache2和/ etc/mysql的權利。我使用了兩個,因爲我無法弄清楚如何在一箇中做到這一點。第一個作品:本地rsync包含/排除

rsync -vahtl --dry-run --log-file=$LOGFILE --exclude="wp-includes/" --exclude="wp-admin/" --exclude="wp-*.php" /var/www $DROPBOX_FOLDER 

但是當我運行第二個,我嘗試了一堆--include和--exclude指令的變化並沒有什麼作品:

rsync -vahtl --dry-run --log-file=$LOGFILE --include="php5" --exclude="*" /etc $DROPBOX_FOLDER 
rsync -vahtl --dry-run --log-file=$LOGFILE --include="*/" --include="php5/" --exclude="*" /etc $DROPBOX_FOLDER 

等。

回答

0

最快的方法是使用類似this.Would需要進行調整,以你的Linux的味道來運行它作爲一個bash腳本

#!/bin/sh 
# rsync backup script 
rsync -avz --delete-excluded --exclude-from=backup.lst//home/USERNAME/Dropbox/backup 

然後創建一個名爲的backup.lst在目錄中,從 #包括 +的/ etc/PHP5 +的/ etc/apache2的 +的/ etc/mysql的 +在/ var/WWW

將要運行腳本文件
# Exclude 
- /var/www/wp-admin/* 
- /var/www/wp-*.php 
- /var/www/wp-includes/* 
- /etc/* 
- /run/* 
- /proc/* 
- /sys/* 
- /tmp/* 
- lost+found/ 
- /media/* 
- /mnt/* 

這裏有一些排除/包含的例子:

# --exclude "*.o" would exclude all filenames matching *.o 
# --exclude "/foo" would exclude a file in the base directory called foo 
# --exclude "foo/" would exclude any directory called foo. 
# --exclude "/foo/*/bar" would exclude any file called bar two levels below a 
         base directory called foo. 
# --exclude "/foo/**/bar" would exclude any file called bar two or more levels below 
         a base directory called foo. 
# --include "*/" --include "*.c" --exclude "*" 
         would include all directories 
         and C source files 
# --include "foo/" --include "foo/bar.c" --exclude "*" 
       would include only foo/bar.c (the foo/ directory must be 
       explicitly included or it would be excluded by the "*")