mirror of
https://github.com/laurent22/rsync-time-backup
synced 2024-11-10 14:14:16 +00:00
Sort fn_find_backups newest first.
This commit is contained in:
parent
9ece9fbec3
commit
08d090f19c
1 changed files with 6 additions and 6 deletions
|
@ -40,7 +40,7 @@ fn_parse_date() {
|
|||
}
|
||||
|
||||
fn_find_backups() {
|
||||
find "$DEST_FOLDER" -type d -name "????-??-??-??????" -prune
|
||||
find "$DEST_FOLDER" -type d -name "????-??-??-??????" -prune | sort -r
|
||||
}
|
||||
|
||||
fn_expire_backup() {
|
||||
|
@ -108,7 +108,7 @@ export IFS=$'\n' # Better for handling spaces in filenames.
|
|||
PROFILE_FOLDER="$HOME/.rsync_tmbackup"
|
||||
LOG_FILE="$PROFILE_FOLDER/$NOW.log"
|
||||
DEST=$DEST_FOLDER/$NOW
|
||||
PREVIOUS_DEST=$(fn_find_backups | sort | tail -n 1)
|
||||
PREVIOUS_DEST=$(fn_find_backups | head -n 1)
|
||||
INPROGRESS_FILE=$DEST_FOLDER/backup.inprogress
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
|
@ -129,10 +129,10 @@ if [ -f "$INPROGRESS_FILE" ]; then
|
|||
# - Last backup is moved to current backup folder so that it can be resumed.
|
||||
# - 2nd to last backup becomes last backup.
|
||||
fn_log_info "$INPROGRESS_FILE already exists - the previous backup failed or was interrupted. Backup will resume from there."
|
||||
LINE_COUNT=$(fn_find_backups | sort | tail -n 2 | wc -l)
|
||||
LINE_COUNT=$(fn_find_backups | wc -l)
|
||||
mv -- "$PREVIOUS_DEST" "$DEST"
|
||||
if [ "$LINE_COUNT" -gt 1 ]; then
|
||||
PREVIOUS_PREVIOUS_DEST=$(fn_find_backups | sort | tail -n 2 | head -n 1)
|
||||
PREVIOUS_PREVIOUS_DEST=$(fn_find_backups | sed -n '2p')
|
||||
PREVIOUS_DEST=$PREVIOUS_PREVIOUS_DEST
|
||||
else
|
||||
PREVIOUS_DEST=""
|
||||
|
@ -173,7 +173,7 @@ while [ "1" ]; do
|
|||
|
||||
# Default value for $prev ensures that the most recent backup is never deleted.
|
||||
prev="0000-00-00-000000"
|
||||
for fname in $(fn_find_backups | sort -r); do
|
||||
for fname in $(fn_find_backups); do
|
||||
date=$(basename "$fname")
|
||||
stamp=$(fn_parse_date $date)
|
||||
|
||||
|
@ -262,7 +262,7 @@ while [ "1" ]; do
|
|||
exit 1
|
||||
fi
|
||||
|
||||
OLD_BACKUP_PATH=$(fn_find_backups | head -n 1)
|
||||
OLD_BACKUP_PATH=$(fn_find_backups | tail -n 1)
|
||||
if [ "$OLD_BACKUP_PATH" == "" ]; then
|
||||
fn_log_error "No space left on device, and cannot get path to oldest backup to delete."
|
||||
exit 1
|
||||
|
|
Loading…
Reference in a new issue