Add option to sort backup directories based on modification time.
By default, ccollect.sh sorts backup directories based on last change time (ctime). This adds the option to sort based on modification time (mtime). I have updated doc/ccollect.text but it needs some work to simplify and explain the issue.
This commit is contained in:
parent
97df2c14de
commit
010449bafa
2 changed files with 21 additions and 4 deletions
12
ccollect.sh
12
ccollect.sh
|
@ -285,7 +285,7 @@ while [ "${i}" -lt "${no_sources}" ]; do
|
|||
c_pre_exec="${backup}/pre_exec"
|
||||
c_post_exec="${backup}/post_exec"
|
||||
for opt in exclude verbose very_verbose rsync_options summary delete_incomplete \
|
||||
remote_host rsync_failure_codes ; do
|
||||
remote_host rsync_failure_codes mtime ; do
|
||||
if [ -f "${backup}/$opt" -o -f "${backup}/no_$opt" ]; then
|
||||
eval c_$opt=\"${backup}/$opt\"
|
||||
else
|
||||
|
@ -293,6 +293,13 @@ while [ "${i}" -lt "${no_sources}" ]; do
|
|||
fi
|
||||
done
|
||||
|
||||
#
|
||||
# With mtime option, sort backup directories with mtime (default is ctime)
|
||||
#
|
||||
if [ -f "$c_mtime" ] ; then
|
||||
TSORT="t"
|
||||
fi
|
||||
|
||||
#
|
||||
# Marking backups: If we abort it's not removed => Backup is broken
|
||||
#
|
||||
|
@ -496,9 +503,6 @@ while [ "${i}" -lt "${no_sources}" ]; do
|
|||
#
|
||||
# Check for backup directory to clone from: Always clone from the latest one!
|
||||
#
|
||||
# Use ls -1c instead of -1t, because last modification maybe the same on all
|
||||
# and metadate update (-c) is updated by rsync locally.
|
||||
#
|
||||
last_dir="$(pcmd ls -${TSORT}p1 "${ddir}" | grep '/$' | head -n 1)" || \
|
||||
_exit_err "Failed to list contents of ${ddir}."
|
||||
|
||||
|
|
|
@ -360,6 +360,7 @@ Additionally a source may have the following files:
|
|||
- `delete_incomplete` delete incomplete backups
|
||||
- `remote_host` host to backup to
|
||||
- `rsync_failure_codes` list of rsync exit codes that indicate complete failure
|
||||
- `mtime` Sort backup directories based on their modification time
|
||||
|
||||
|
||||
Example:
|
||||
|
@ -584,6 +585,18 @@ be left in the destination directory indicating failure of this backup. If
|
|||
you have enabled delete_incomplete, then this backup will be deleted during
|
||||
the next ccollect run on the same interval.
|
||||
|
||||
mtime
|
||||
^^^^^
|
||||
By default, ccollect.sh chooses the most recent backup directory for cloning or
|
||||
the oldest for deletion based on the directory's last change time (ctime).
|
||||
With this option, the sorting is done based on modification time (mtime). With
|
||||
this version of ccollect.sh, the ctime and mtime of your backups will normally
|
||||
be the same and this option has no effect. However, if you, for example, move
|
||||
your backups to another hard disk using cp -a or rsync -a, you should use this
|
||||
option because the ctimes are not preserved during such operations.
|
||||
|
||||
If you have any backups in your repository made with ccollect version 0.7.1 or
|
||||
earlier, do not use this option and do not move your repository.
|
||||
|
||||
Hints
|
||||
-----
|
||||
|
|
Loading…
Reference in a new issue