mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2024-11-25 22:21:04 +01:00
Adapted pull primary backups to hardlinks
This commit is contained in:
parent
f4b8e2b8dd
commit
0727b179a6
@ -11,26 +11,35 @@ directories="$(ssh "$source_host" find "$source_path" -maxdepth 1 -type d)" || e
|
|||||||
|
|
||||||
for backup_type_dir in $directories; do
|
for backup_type_dir in $directories; do
|
||||||
if [ "$backup_type_dir" != "$source_path" ]; then
|
if [ "$backup_type_dir" != "$source_path" ]; then
|
||||||
# this folder is neccessary to make restricted rsync possible:
|
# folder which contains versions
|
||||||
current_version="$backup_type_dir/versions/current/"
|
versions_dir="$backup_type_dir/versions/"
|
||||||
# this is the folder where the versions will be copied to:
|
# link name of last backup
|
||||||
diff_store="$backup_type_dir/versions/$(date '+%Y%m%d%H%M%S')/"
|
latest_version_link="$backup_type_dir/latest"
|
||||||
# this is the folder which contains the actual backup:
|
# this folder contains the last backup
|
||||||
latest_path="$backup_type_dir/latest/"
|
latest_version_dir="$versions_dir$(date '+%Y%m%d%H%M%S')/"
|
||||||
|
# this is the link name of the previous version
|
||||||
|
previous_version_link="$backup_type_dir/previous"
|
||||||
# source path of the backup files:
|
# source path of the backup files:
|
||||||
remote_source_path="$source_host:$latest_path"
|
remote_source_path="$source_host:$latest_version_link/"
|
||||||
# file in which the logs will be saved:
|
|
||||||
log_path="$backup_type_dir/log.txt"
|
#identifiy previous version
|
||||||
|
versions=( $(basename -a "$versions_dir"*/ | sort) )|| exit 1
|
||||||
|
last_version="${versions[-1]}" || exit 1
|
||||||
|
previous_version_dir="$versions_dir$last_version/"
|
||||||
|
|
||||||
# create working folders:
|
# create working folders:
|
||||||
mkdir -vp "$latest_path"
|
mkdir -vp "$latest_version_dir"
|
||||||
mkdir -vp "$diff_store"
|
|
||||||
rm -vr "$current_version"
|
# delete links
|
||||||
mkdir -vp "$current_version"
|
rm -v "$latest_version_link"
|
||||||
|
rm -v "$previous_version_link"
|
||||||
|
|
||||||
|
# create links
|
||||||
|
ln -vs "$latest_version_dir" "$latest_version_link" || exit 1
|
||||||
|
ln -vs "$previous_version_dir" "$previous_version_link"|| exit 1
|
||||||
|
|
||||||
# do backup:
|
# do backup:
|
||||||
rsync -abP --delete --delete-excluded --rsync-path="sudo rsync" --log-file="$log_path" --backup-dir="$current_version" "$remote_source_path" "$latest_path" || ((errors+=1));
|
rsync -abP --delete --delete-excluded --rsync-path="sudo rsync" --link-dest="$previous_version_link" "$remote_source_path" "$latest_version_link" || ((errors+=1));
|
||||||
mv -v "$current_version"* "$diff_store"
|
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
exit $errors;
|
exit $errors;
|
||||||
|
@ -9,7 +9,7 @@ fi
|
|||||||
# define executable commands
|
# define executable commands
|
||||||
hashed_machine_id_command="sha256sum /etc/machine-id";
|
hashed_machine_id_command="sha256sum /etc/machine-id";
|
||||||
find_command="find /Backups/{{hashed_machine_id.stdout}}/ -maxdepth 1 -type d";
|
find_command="find /Backups/{{hashed_machine_id.stdout}}/ -maxdepth 1 -type d";
|
||||||
rsync_command="sudo rsync --server --sender -blogDtpre.iLsfxCIvu --backup-dir /Backups/{{hashed_machine_id.stdout}}/docker-volume-backup/diffs/current/ . /Backups/{{hashed_machine_id.stdout}}/docker-volume-backup/latest/"
|
rsync_command="sudo rsync --server --sender -blogDtpre.iLsfxCIvu . /Backups/{{hashed_machine_id.stdout}}/docker-volume-backup/latest"
|
||||||
|
|
||||||
# filter commands
|
# filter commands
|
||||||
case "$SSH_ORIGINAL_COMMAND" in
|
case "$SSH_ORIGINAL_COMMAND" in
|
||||||
|
Loading…
Reference in New Issue
Block a user