Skip to content

Commit

Permalink
Add option to use local time instead of UTC
Browse files Browse the repository at this point in the history
Closes #17, closes #18.
  • Loading branch information
aghitza authored and alexjurkiewicz committed Nov 29, 2016
1 parent bb50e2b commit 6727b68
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ Notes on behaviour:
- Keep the most recent 12 monthly backups, and delete any older
ones.
- Do not delete any yearly backups.
- Times in archive names use UTC, not the server's timezone.

TODO
----
Expand Down
11 changes: 10 additions & 1 deletion acts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ fi
# Use default values if anything is not set
verbose="${verbose=0}"
hostname="${hostname=$(hostname -s)}"
uselocaltime="${uselocaltime=0}"
backuptargets="${backuptargets=}"
prebackupscript="${prebackupscript=}"
postbackupscript="${postbackupscript=}"
Expand All @@ -84,6 +85,14 @@ if [ -z "$backuptargets" ] ; then
die "config-error message=\"\$backuptargets is not set in acts.conf.\""
fi

if [ "$uselocaltime" = 0 ] ; then
utc="-u"
elif [ "$uselocaltime" = 1 ] ; then
utc=""
else
die "config-error message=\"invalid \$uselocaltime in acts.conf; valid options are 0 (for UTC) or 1 (for local time).\""
fi

# Create the lock. mkdir is atomic test/set, so use that instead of the typical test -f/touch combo
if [ -d "$lockfile" ] ; then
die "acts-error message=\"$lockfile exists referencing PID $(cat "$lockfile/pid" 2>/dev/null || echo "<none>"). Hint: If acts is not already running, rm -rf $lockfile.\""
Expand All @@ -108,7 +117,7 @@ archives=$(echo "$archives_unsorted" | sort -n)

# When is now?
# Instead of re-running date, be paranoid the day was microseconds away from ending
today=$(date -u "+%Y-%m-%d_%H:%M:%S")
today=$(date "$utc" "+%Y-%m-%d_%H:%M:%S")
year=$(echo "$today" | cut -d_ -f1 | cut -d- -f1)
month=$(echo "$today" | cut -d_ -f1 | cut -d- -f2)
# day=$(echo "$today" | cut -d_ -f1 | cut -d- -f3) # unused
Expand Down
5 changes: 5 additions & 0 deletions acts.conf.sample
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ verbose=1
# Default: $(hostname -s)
#hostname=$(hostname)

# uselocaltime
# Use local time instead of UTC for the archive date and timestamps.
# Default: 0 (i.e. use UTC)
#uselocaltime=1

# prebackupscript
# This script is run before backups are created. Make sure it's executable.
# Default: unset
Expand Down

0 comments on commit 6727b68

Please sign in to comment.