]> git.llucax.com Git - software/bacap.git/commitdiff
Support "--include-from" rsync option
authorRodrigo Campos <rodrigo@sdfg.com.ar>
Mon, 12 Jul 2010 16:26:11 +0000 (13:26 -0300)
committerLeandro Lucarella <llucax@gmail.com>
Mon, 12 Jul 2010 16:38:30 +0000 (13:38 -0300)
Signed-off-by: Rodrigo Campos <rodrigo@sdfg.com.ar>
README
bacap

diff --git a/README b/README
index c15200c97064fada6d8602b799e3590df8c3147b..67b565f96505f62ac775e851e649c5d0c2bff0c8 100644 (file)
--- a/README
+++ b/README
@@ -120,6 +120,10 @@ backup rata's home::
 
        echo /home/rata/ > $CONFIG_PATH/$LOCALHOST/excludes
 
+Also, if you don't want to exclude files matching some pattern, you can create
+a file named ``includes`` with the patterns you want to include (you can use
+anything supported by the ``--include-from`` rsync_ option)
+
 That's pretty much it. If you want to add other hosts, just create the host
 directory and the needed host configuration files.
 
diff --git a/bacap b/bacap
index dd83d2ea489416b7898ff99517c2c3875851b2c8..062902adad5c0dd07f82d7f7de5b9b096cb86ee3 100755 (executable)
--- a/bacap
+++ b/bacap
@@ -100,9 +100,11 @@ do
        [ "$host" != "$LOCALHOST" ] &&
                src=`awk "{print \"$host:\"\\$1}" "$host_path/paths"`
        exclude="$host_path/excludes"
+       include="$host_path/includes"
        current_link="$host_backup_path/current"
        current_dir="$host_backup_path/`readlink \"$current_link\"`"
        exclude_flags=
+       include_flags=
        plog "-----------------------------------------------------------------"
        plog "Backup for host $host"
        plog "-----------------------------------------------------------------"
@@ -117,12 +119,14 @@ do
                perror "$host is down, skipping..." &&
                continue
        [ -r "$exclude" ] &&
-               exclude_flags=" --exclude-from=$exclude --delete-excluded"
+               extra_flags="--exclude-from=$exclude --delete-excluded"
+       [ -r "$include" ] &&
+               extra_flags="$extra_flags --include-from=$include"
        plog "Rotating backup..."
        $run cp -al $V "$current_dir" "$dst" ||
                ret=$(($ret+1))
        plog "Running rsync..."
-       $run rsync $RSYNC_FLAGS $exclude_flags $src "$dst/" ||
+       $run rsync $RSYNC_FLAGS $extra_flags $src "$dst/" ||
                ret=$(($ret+1))
        plog "Moving current..."
        $run rm $V "$current_link" ||