System: настройка rsnapshot

* изменены пути исключения при синхронизации
* alpha,beta,gamma вместо daily,weekly,monthly
* удалён скрипт для реализации логики ежедневного, еженедельного и
ежемесяыного бэкапа
mhiretskiy
parent 9e1d8541a2
commit cfec8862d0

@ -7,14 +7,6 @@
<text>\1/usr/bin/ssh</text>
<reg>^#?(cmd_du\s+).*$</reg>
<text>\1/usr/bin/du</text>
<reg>^(retain\s+)alpha\s+\d+.*$</reg>
<text>\1daily\t5</text>
<reg>^(retain\s+)beta\s+\d+.*$</reg>
<text>\1weekly\t4</text>
<reg>^(retain\s+)gamma\s+\d+.*$</reg>
<text>\1monthly\t3</text>
<reg>^#?retain\s+delta.*\n</reg>
<text></text>
<reg>^#?(rsync_short_args\s+).*$</reg>
<text>\1-aAX</text>
<reg>^#?(rsync_long_args\s+).*$</reg>

@ -1,27 +1,17 @@
- /container/*
- /dev
- /linux/*
- /dev/*
- /lost+found
- /lxc/*/calculate/packages
- /lxc/**/remote/distfiles
- /lxc/*/rootfs/proc
- /lxc/*/rootfs/run
- /lxc/*/rootfs/sys
- /lxc/*/rootfs/tmp
- /lxc/*/rootfs/usr/portage
- /lxc/*/rootfs/var/calculate/packages
- /lxc/*/rootfs/var/lib/layman
- /lxc/*/rootfs/var/log
- /tmp/*
- /usr/portage/*
- /var/lib/layman/*
- /lxc/*/snaps
- /lxc/*/rootfs/dev/*
- /lxc/*/rootfs/tmp/*
- /lxc/*/rootfs/usr/portage/*
- /lxc/*/rootfs/var/lib/layman/*
- /lxc/*/rootfs/var/log/*
- /lxc/**/calculate/packages
- /lxc/**/remote/distfiles
- /packages
- /proc
- /remote/distfiles
- /run
- /snapshots/*
- /sys
- /tmp
- /usr/portage/*
- /var/calculate/snapshots/*
- /var/lib/layman/*
- /var/log/*
- /vps/*

@ -1,65 +0,0 @@
# Calculate chmod=0755 path=/usr/libexec
#!/bin/bash
# Copyright (C) 2018 Mir Calculate Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# The script allows you to create daily, weekly (from Monday), and monthly
# (every 4 weeks) backups automatically, with a single daily startup.
weekseconds="$(( 60 * 60 * 24 * 7 ))"
get_value() {
awk -F"\t" "{if (\$1 == \"$1\") print \$2}" | tail -1
}
get_retain_value() {
awk -F"\t" "{if (\$1 == \"retain\" && \$2 == \"$1\") print \$3}" | tail -1
}
declare -A res
base_configfile=/etc/rsnapshot.conf
configfiles=${@:-$base_configfile}
for configfile in $configfiles
do
rsnapshot -c $configfile sync
res["$configfile"]=$?
done
for configfile in $configfiles
do
snapshot_root="$(cat $base_configfile $configfile | get_value snapshot_root)"
retain_daily="$(cat $base_configfile $configfile | get_retain_value daily)"
# calculating the day of the week when need to do rotation, so that a copy
# comes in weekly from Monday
if [[ $(date +"%w") -eq $(( ($retain_daily + 1) % 7 )) ]]
then
# it's time to make a monthly backup
if [[ $(( $(date +"%s") / $weekseconds % 4 )) -eq 0 ]]
then
rsnapshot -c $configfile monthly
fi
rsnapshot -c $configfile weekly
fi
# fix the backup as daily if there was no error
if [[ ${res["$configfile"]} -ne 1 ]]
then
rsnapshot -c $configfile daily
# write current time to backup for reference
date >${snapshot_root}/daily.0/timestamp
fi
done
Loading…
Cancel
Save