Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use local time instead of utc #132

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
zfs-auto-snapshot.code-workspace
3 changes: 3 additions & 0 deletions src/zfs-auto-snapshot.8
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ Keep NUM recent snapshots and destroy older snapshots.
\fB\-l\fR, \fB\-\-label\fR=\fILAB\fR
LAB is usually 'hourly', 'daily', or 'monthly'.
.TP
\fB\-L\fR, \fB\-\-local\-time\fR
Use local time instead of UTC for snapshots.
.TP
\fB\-p\fR, \fB\-\-prefix\fR=\fIPRE\fR
PRE is 'zfs\-auto\-snap' by default.
.TP
Expand Down
17 changes: 14 additions & 3 deletions src/zfs-auto-snapshot.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ opt_pre_snapshot=''
opt_post_snapshot=''
opt_do_snapshots=1
opt_min_size=0
opt_local=0

# Global summary statistics.
DESTRUCTION_COUNT='0'
Expand All @@ -65,6 +66,7 @@ print_usage ()
-h, --help Print this usage message.
-k, --keep=NUM Keep NUM recent snapshots and destroy older snapshots.
-l, --label=LAB LAB is usually 'hourly', 'daily', or 'monthly'.
-L, --local-time Use local time for snapshot names instead of UTC.
-p, --prefix=PRE PRE is 'zfs-auto-snap' by default.
-q, --quiet Suppress warnings and notices at the console.
--send-full=F Send zfs full backup. Unimplemented.
Expand Down Expand Up @@ -231,12 +233,12 @@ else
fi

GETOPT=$($GETOPT_BIN \
--longoptions=default-exclude,dry-run,fast,skip-scrub,recursive \
--longoptions=default-exclude,dry-run,fast,local-time,skip-scrub,recursive \
--longoptions=event:,keep:,label:,prefix:,sep: \
--longoptions=debug,help,quiet,syslog,verbose \
--longoptions=pre-snapshot:,post-snapshot:,destroy-only \
--longoptions=min-size: \
--options=dnshe:l:k:p:rs:qgvm: \
--options=dnshe:l:Lk:p:rs:qgvm: \
-- "$@" ) \
|| exit 128

Expand Down Expand Up @@ -295,6 +297,10 @@ do
opt_label="$2"
shift 2
;;
(-L|--local-time)
opt_local=1
shift 1
;;
(-m|--min-size)
opt_min_size="$2"
shift 2
Expand Down Expand Up @@ -585,7 +591,12 @@ SNAPPROP="-o com.sun:auto-snapshot-desc='$opt_event'"
# ISO style date; fifteen characters: YYYY-MM-DD-HHMM
# On Solaris %H%M expands to 12h34.
# We use the shortfirm -u here because --utc is not supported on macos.
DATE=$(date -u +%F-%H%M)
if [ $opt_local -eq 1 ]
then
DATE=$(date +%F-%H%M)
else
DATE=$(date -u +%F-%H%M)
fi

# The snapshot name after the @ symbol.
SNAPNAME="${opt_prefix:+$opt_prefix$opt_sep}${opt_label:+$opt_label}-$DATE"
Expand Down