Purrsync
is an rsync wrapper for syncing files based on package collections.
The simplest invocation is: Synchronizing from a MAINFILE (file list) everything from SRC to DEST.
purrsync -m $MAINFILE $SRC $DEST
Here is a realistic example of the above.
mkdir -v /tmp/etc
cd /etc
find . > /tmp/mainfile
purrsync -m /tmp/mainfile /etc /tmp/etc
An ignore file list can be used.
cd /etc
find . > /tmp/mainfile
find -iname \*.key > /tmp/ignorefile
purrsync -m /tmp/mainfile -i /tmp/ignorefile /etc /tmp/etc
Instead of creating files, purrsync
can run the commands for you.
cd /etc
purrsync --main-exec "find" --ignore-exec "find -iname \*.key" /etc /tmp/etc
The main goal of this script was to sort backup configurations for packages on a per-package basis. On Gentoo this can be achieved with the following.
purrsync -p -o -x "find /etc" -e "qlist {}" -L "qfile /etc | awk '{ print \$1 }'" / /tmp/etc
- The
-p
flag is required for package sorting. - The
-o
flag is for creating a special directory for orphaned files (without packages). - The
-x
flag is synonymous with--main-exec
. - The
-e
flag runs"qlist {}"
for every package, where{}
is replaced with the package name. - The
-L
flag runs"qfile /etc | awk '{print \$1 }'"
on/bin/sh
to get a list of the relevant packages. These names are fed intoqlist {}
.
Only the set intersection between -x
and -e
are synchronized into the
package destinations.
Arguments can be passed to rsync
.
purrsync -m FILELIST --rsync-args="-v" / /tmp/root
The path to the rsync
binary can be specified,
purrsync -m FILELIST --rsync-bin="/usr/bin/rsync" / /tmp/root
by default purrsync
uses the which
command to find the location of rsync
.
A backup directory can be given to purrsync
relative to the main
, pkg
and
orphan
directories in the destination.
purrsync --backup-dir="backup-dir" -m FILELIST / /tmp/root
This can be used to create incremental backup snapshots.
purrsync --rsync-args="-u" -b "$(date +%F-%I%M%p-%Z)" -m FILELIST / /tmp/root
The rsync
-u
option specifies to only update the destination if files are
newer on the source.
The destination directory is structured as follows.
- destination
- main
- root
- backup-dir
- orphan
- root
- backup-dir
- pkg
- package_name
- root
- backup-dir
- package_name
- main
The destination passed to rsync
always ends in root.
I hope this has been a helpful guide.
If you have any suggestions, comments or would like to submit a PR, please be in touch.
Have a nice day! :)