From 1ae8b4c33af175545d6afe99aeb7a21896960a35 Mon Sep 17 00:00:00 2001 From: Mohammed Rafi KC Date: Thu, 5 Feb 2015 16:12:53 +0530 Subject: snapshot: append timestamp with snapname Appending GMT time stamp with snapname by default. If no-timestamp flag is given during snapshot creation, then time stamp will not append with snapname; Initial consumer of this feature is Samba's Shadow Copy feature. This feature allows Windows user to get previous revisions of a file. For this feature to work snapshot names under .snaps folder (USS) should have timestamp in following format appended: @GMT-YYYY.MM.DD-hh.mm.ss PS: https://www.samba.org/samba/docs/man/manpages/vfs_shadow_copy2.8.html This format is configurable by Samba conf file. Due to a limitation in Windows directory access the exact format cannot be used by USS. Therefore we have modified the file format to: _GMT-YYYY.MM.DD-hh.mm.ss Snapshot scheduling feature also required to append timestamp to the snapshot name therefore timestamp is appended in snapshot creation itself instead of doing the changes in snapview server. More info: https://www.mail-archive.com/gluster-users@gluster.org/msg18895.html Change-Id: Idac24670948cf4c0fbe916ea6690e49cbc832d07 BUG: 1189473 Signed-off-by: Mohammed Rafi KC Reviewed-on: http://review.gluster.org/9597 Tested-by: Gluster Build System Reviewed-by: Rajesh Joseph Reviewed-by: Krishnan Parthasarathi Tested-by: Krishnan Parthasarathi --- cli/src/cli-cmd-parser.c | 20 +++++++++++++++++--- cli/src/cli-cmd-snapshot.c | 3 ++- 2 files changed, 19 insertions(+), 4 deletions(-) (limited to 'cli/src') diff --git a/cli/src/cli-cmd-parser.c b/cli/src/cli-cmd-parser.c index bbec6aa5f8d..0981f11b7be 100644 --- a/cli/src/cli-cmd-parser.c +++ b/cli/src/cli-cmd-parser.c @@ -3397,7 +3397,9 @@ cli_snap_create_parse (dict_t *dict, const char **words, int wordcount) { /* Filling volume name in the dictionary */ for (i = cmdi + 1 ; i < wordcount && (strcmp (words[i], "description")) != 0 - && (strcmp (words[i], "force") != 0); i++) { + && (strcmp (words[i], "force") != 0) + && (strcmp (words[i], "no-timestamp") != 0); + i++) { volcount++; /* volume index starts from 1 */ ret = snprintf (key, sizeof (key), "volname%"PRIu64, volcount); @@ -3437,13 +3439,24 @@ cli_snap_create_parse (dict_t *dict, const char **words, int wordcount) { /* Verify how we got out of "for" loop, * if it is by reaching wordcount limit then goto "out", - * because we need not parse for "description" and "force" - * after this. + * because we need not parse for "description","force" and + * "no-timestamp" after this. */ if (i == wordcount) { goto out; } + if (strcmp (words[i], "no-timestamp") == 0) { + ret = dict_set_str (dict, "no-timestamp", "true"); + if (ret) { + gf_log ("cli", GF_LOG_ERROR, "Could not save " + "time-stamp option"); + } + if (i == (wordcount-1)) + goto out; + i++; + } + if ((strcmp (words[i], "description")) == 0) { ++i; if (i > (wordcount - 1)) { @@ -4291,6 +4304,7 @@ cli_cmd_snapshot_parse (const char **words, int wordcount, dict_t **options, case GF_SNAP_OPTION_TYPE_CREATE: /* Syntax : * gluster snapshot create + * [no-timestamp] * [description ] * [force] */ diff --git a/cli/src/cli-cmd-snapshot.c b/cli/src/cli-cmd-snapshot.c index d03b5b99dd0..7c6a52e0a88 100644 --- a/cli/src/cli-cmd-snapshot.c +++ b/cli/src/cli-cmd-snapshot.c @@ -82,7 +82,8 @@ struct cli_cmd snapshot_cmds[] = { cli_cmd_snapshot_help_cbk, "display help for snapshot commands" }, - { "snapshot create [description ] [force]", + { "snapshot create [no-timestamp] " + "[description ] [force]", cli_cmd_snapshot_cbk, "Snapshot Create." }, -- cgit