Use git submodules
With submodules, you can plant repositories within other repositories without tracking specific details of the sub-repository's changes.
This feature was specifically created for dealing with projects that may rely on dependences that are tracked elsewhere.
I would give some more detailed use cases but I haven't had reason to use this particular feature yet.
Here's the solution I came up to (as of Feb 2017), to be able to fully customize rsync options used by Hyper Backup's tasks.
Tweaking DiskStation's rsync executable
Difficult to say if tweaking HyperBackup configuration and tasks files is possible, but I could come to the conclusion that it was using the rsync binary present in /usr/bin/
. The rest is to set an intermediate script that tweaks the passed options up.
- connect to DiskStation server via SSH with the 'admin' user
sudo -i
et enter the same password as the 'admin' user
mv /usr/bin/rsync /usr/bin/rsync.orig
touch /usr/bin/rsync
chmod 4755 /usr/bin/rsync
echo '#!/bin/sh
exec /usr/bin/rsync.orig "$@" --option-you-want-to-add' > /usr/bin/rsync
Any other softer solution is welcome.
Making sure the modification will resist updates
I am not sure whether or not DSM manages the system's rsync executable, and if so, a DSM update could occur the modification we made to vanish into the void. Can anyone confirm that?
If so, I would then come up with a script, which I would program via Control Panel
> Task Scheduler
regularly (everyday at midnight for example), to ensure the modification will persist over updates, and that updates of the rsync binary itself will be taken into account.
First, I would set my modified rsync script to a path where I can make it evolve (if my modifications have to change over time):
/usr/local/bin/rsync_modified.sh :
#!/bin/sh
# This script is a custom modification script
# It calls the original binary rsync with modified options
# ordering to kill all child processes if receiving term signal
trap 'pkill -P $$' EXIT
# args to array
args2array () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}
ARGS=$(args2array "$@")
# ...whatever modification you want to make on $ARGS...
# setting arguments again, from $ARGS
eval "set -- ${ARGS[@]}"
/usr/bin/rsync.orig "$@"
# Notes: the args2array call and the arguments setting in the end helps
# giving rsync.orig the arguments as they would be passed through direct
# call. Adding string or expanded arrays during the call of rsync.orig has
# revealed to fail in some cases, where rsync would ignore some of the
# added parameters.
then I would create this script which I could program in the Scheduled Tasks (with user 'root')
/usr/local/bin/rsyncUpdateManager.sh :
#!/bin/sh
# Make sure the modified version of rsync is not overwritten
# and that updates of the original rsync binary are taken into account.
# init
usageFile="/usr/bin/rsync"
origFile="/usr/bin/rsync.orig"
backupFile="/usr/bin/rsync.orig"
modificationScript="/usr/local/bin/rsync_modified.sh"
# check if usage file is a binary
grep -qI . $usageFile && TYPE="TEXT" || TYPE="BINARY"
if [ $TYPE == "BINARY" ]
then
# 1st installation or DSM updated rsync
if [ -f $origFile ]
then
# a original file already exists (probably created by this script)
# we back it up
NOW=$(date +"%Y%m%d_%H%M%S")
mv $origFile "${backupFile}.$NOW.bak"
fi
# rename binary file as original file
mv $usageFile $origFile
fi
# copy modification script in the place of usage file
cp $modificationScript $usageFile
# giving it the same rights as original file (on DiskStation server)
chmod 4755 $usageFile
Best Answer
If you work with opened files like a database, a direct
rsync
can be a bad idea, sincersync
won’t read atomically all the blocks of all the files of the database. The most atomic way would need a system with snapshots enabled. This needs a dedicatedlvm
partition, or a file system likebtrfs
orzfs
. When the partition is snapshoted, yourrsync
can work freely on a stable set of files. The--delay-updates
may be used to make remote application more atomic.