mirror of
https://github.com/laurent22/rsync-time-backup
synced 2024-12-13 05:32:31 +00:00
Added option to disable automatically purging old backups when out of space.
This commit is contained in:
parent
4af7610dd1
commit
b0654c96e0
2 changed files with 17 additions and 0 deletions
|
@ -25,6 +25,7 @@ On macOS, it has a few disadvantages compared to Time Machine - in particular it
|
||||||
--strategy Set the expiration strategy. Default: "1:1 30:7 365:30" means after one
|
--strategy Set the expiration strategy. Default: "1:1 30:7 365:30" means after one
|
||||||
day, keep one backup per day. After 30 days, keep one backup every 7 days.
|
day, keep one backup per day. After 30 days, keep one backup every 7 days.
|
||||||
After 365 days keep one backup every 30 days.
|
After 365 days keep one backup every 30 days.
|
||||||
|
--no-auto-expire Set option to disable automatically purging old backups when out of space.
|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
|
|
||||||
|
@ -91,6 +92,10 @@ To display the rsync options that are used for backup, run `./rsync_tmbackup.sh
|
||||||
|
|
||||||
rsync_tmbackup --rsync-set-flags "--numeric-ids --links --hard-links \
|
rsync_tmbackup --rsync-set-flags "--numeric-ids --links --hard-links \
|
||||||
--one-file-system --archive --no-perms --no-groups --itemize-changes" /src /dest
|
--one-file-system --archive --no-perms --no-groups --itemize-changes" /src /dest
|
||||||
|
|
||||||
|
## No automatic backup expiration
|
||||||
|
|
||||||
|
An option to diable the default behaviour to purge old backups when out of space. This option is set with the `--no-auto-expire` flag.
|
||||||
|
|
||||||
|
|
||||||
## How to restore
|
## How to restore
|
||||||
|
|
|
@ -46,6 +46,8 @@ fn_display_usage() {
|
||||||
echo " --strategy Set the expiration strategy. Default: \"1:1 30:7 365:30\" means after one"
|
echo " --strategy Set the expiration strategy. Default: \"1:1 30:7 365:30\" means after one"
|
||||||
echo " day, keep one backup per day. After 30 days, keep one backup every 7 days."
|
echo " day, keep one backup per day. After 30 days, keep one backup every 7 days."
|
||||||
echo " After 365 days keep one backup every 30 days."
|
echo " After 365 days keep one backup every 30 days."
|
||||||
|
echo " --no-auto-expire Disable automatically deleting backups when out of space. Instead an error"
|
||||||
|
echo " is logged, and the backup is aborted."
|
||||||
echo ""
|
echo ""
|
||||||
echo "For more detailed help, please see the README file:"
|
echo "For more detailed help, please see the README file:"
|
||||||
echo ""
|
echo ""
|
||||||
|
@ -215,6 +217,7 @@ EXCLUSION_FILE=""
|
||||||
LOG_DIR="$HOME/.$APPNAME"
|
LOG_DIR="$HOME/.$APPNAME"
|
||||||
AUTO_DELETE_LOG="1"
|
AUTO_DELETE_LOG="1"
|
||||||
EXPIRATION_STRATEGY="1:1 30:7 365:30"
|
EXPIRATION_STRATEGY="1:1 30:7 365:30"
|
||||||
|
AUTO_EXPIRE="1"
|
||||||
|
|
||||||
RSYNC_FLAGS="-D --compress --numeric-ids --links --hard-links --one-file-system --itemize-changes --times --recursive --perms --owner --group --stats --human-readable"
|
RSYNC_FLAGS="-D --compress --numeric-ids --links --hard-links --one-file-system --itemize-changes --times --recursive --perms --owner --group --stats --human-readable"
|
||||||
|
|
||||||
|
@ -246,6 +249,9 @@ while :; do
|
||||||
LOG_DIR="$1"
|
LOG_DIR="$1"
|
||||||
AUTO_DELETE_LOG="0"
|
AUTO_DELETE_LOG="0"
|
||||||
;;
|
;;
|
||||||
|
--no-auto-expire)
|
||||||
|
AUTO_EXPIRE="0"
|
||||||
|
;;
|
||||||
--)
|
--)
|
||||||
shift
|
shift
|
||||||
SRC_FOLDER="$1"
|
SRC_FOLDER="$1"
|
||||||
|
@ -459,6 +465,12 @@ while : ; do
|
||||||
NO_SPACE_LEFT="$(grep "No space left on device (28)\|Result too large (34)" "$LOG_FILE")"
|
NO_SPACE_LEFT="$(grep "No space left on device (28)\|Result too large (34)" "$LOG_FILE")"
|
||||||
|
|
||||||
if [ -n "$NO_SPACE_LEFT" ]; then
|
if [ -n "$NO_SPACE_LEFT" ]; then
|
||||||
|
|
||||||
|
if [[ $AUTO_EXPIRE == "0" ]]; then
|
||||||
|
fn_log_error "No space left on device, and automatic purging of old backups is disabled."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
fn_log_warn "No space left on device - removing oldest backup and resuming."
|
fn_log_warn "No space left on device - removing oldest backup and resuming."
|
||||||
|
|
||||||
if [[ "$(fn_find_backups | wc -l)" -lt "2" ]]; then
|
if [[ "$(fn_find_backups | wc -l)" -lt "2" ]]; then
|
||||||
|
|
Loading…
Reference in a new issue