Introduce consistent time sorting
Based on patches by John Lawless <jlawless@redwoodscientific.com>. Skipped the sort changing part (from -tc to -t) c.patch: --- ccollect-0.7.1-b.sh 2009-05-24 21:32:00.000000000 -0700 +++ ccollect-0.7.1-c.sh 2009-05-24 21:39:43.000000000 -0700 @@ -40,10 +40,13 @@ VERSION=0.7.1 RELEASE="2009-02-02" HALF_VERSION="ccollect ${VERSION}" FULL_VERSION="ccollect ${VERSION} (${RELEASE})" +#TSORT="tc" ; NEWER="cnewer" +TSORT="t" ; NEWER="newer" + # # CDATE: how we use it for naming of the archives # DDATE: how the user should see it in our output (DISPLAY) # CDATE="date +%Y%m%d-%H%M" @@ -513,14 +516,14 @@ # # 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 -tcp1 "${ddir}" | grep '/$' | head -n 1)" || \ + # Depending on your file system, you may want to sort on: + # 1. mtime (modification time) with TSORT=t, or + # 2. ctime (last change time, usually) with TSORT=tc + last_dir="$(pcmd ls -${TSORT}p1 "${ddir}" | grep '/$' | head -n 1)" || \ _exit_err "Failed to list contents of ${ddir}." # # clone from old backup, if existing # d.patch: --- ccollect-0.7.1-c.sh 2009-05-24 21:39:43.000000000 -0700 +++ ccollect-0.7.1-d.sh 2009-05-24 21:47:09.000000000 -0700 @@ -492,12 +492,12 @@ if [ "${count}" -ge "${c_interval}" ]; then substract=$((${c_interval} - 1)) remove=$((${count} - ${substract})) _techo "Removing ${remove} backup(s)..." - pcmd ls -p1 "$ddir" | grep "^${INTERVAL}\..*/\$" | \ - sort -n | head -n "${remove}" > "${TMP}" || \ + pcmd ls -${TSORT}p1r "$ddir" | grep "^${INTERVAL}\..*/\$" | \ + head -n "${remove}" > "${TMP}" || \ _exit_err "Listing old backups failed" i=0 while read to_remove; do eval remove_$i=\"${to_remove}\" Signed-off-by: Nico Schottelius <nico@ikn.schottelius.org>
This commit is contained in:
parent
a030a98982
commit
62e8190a94
1 changed files with 5 additions and 3 deletions
|
@ -45,9 +45,11 @@ FULL_VERSION="ccollect ${VERSION} (${RELEASE})"
|
|||
#
|
||||
# CDATE: how we use it for naming of the archives
|
||||
# DDATE: how the user should see it in our output (DISPLAY)
|
||||
# TSORT: how to sort: tc = ctime, t = mtime
|
||||
#
|
||||
CDATE="date +%Y%m%d-%H%M"
|
||||
DDATE="date +%Y-%m-%d-%H:%M:%S"
|
||||
TSORT="tc"
|
||||
|
||||
#
|
||||
# unset parallel execution
|
||||
|
@ -491,8 +493,8 @@ while [ "${i}" -lt "${no_sources}" ]; do
|
|||
remove=$((${count} - ${substract}))
|
||||
_techo "Removing ${remove} backup(s)..."
|
||||
|
||||
pcmd ls -p1 "$ddir" | grep "^${INTERVAL}\..*/\$" | \
|
||||
sort -n | head -n "${remove}" > "${TMP}" || \
|
||||
pcmd ls -${TSORT}p1r "$ddir" | grep "^${INTERVAL}\..*/\$" | \
|
||||
head -n "${remove}" > "${TMP}" || \
|
||||
_exit_err "Listing old backups failed"
|
||||
|
||||
i=0
|
||||
|
@ -518,7 +520,7 @@ while [ "${i}" -lt "${no_sources}" ]; do
|
|||
# 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 -tcp1 "${ddir}" | grep '/$' | head -n 1)" || \
|
||||
last_dir="$(pcmd ls -${TSORT}p1 "${ddir}" | grep '/$' | head -n 1)" || \
|
||||
_exit_err "Failed to list contents of ${ddir}."
|
||||
|
||||
#
|
||||
|
|
Loading…
Reference in a new issue