Hi I could not get a custom "shadow:delimiter" for the vfs shadow_copy2 module to work successfully for me with Samba 4.6.2. I did not try previous versions. Based on my testing it seems that an additional line of code is needed in vfs_shadow_copy2.c as shown in the patch below (some comment updates are included too for code readability). Without the below patch, previous versions were not being returned by Samba when using a shadow:delimiter. I was using a sample config of shadow:snapprefix = ^Snap shadow:delimiter = _._ shadow:format = %Y.%m.%d-%H.%M.%S with sample snapshots named: Snap_testing1_._2016.11.01-01.00.01 Snap_prerelease_._2016.12.01-01.00.02 Snap_postrelease_._2017.01.01-01.00.01 Is anyone able to use a custom shadow:delimiter successfully without any modifications to the Samba code? If not, how do I go about getting this patch applied? diff -up vfs_shadow_copy2.c.orig vfs_shadow_copy2.c --- vfs_shadow_copy2.c.orig 2017-03-31 14:53:38.722560396 +0100 +++ vfs_shadow_copy2.c 2017-04-02 22:13:41.943038415 +0100 @@ -1866,16 +1866,19 @@ static bool shadow_copy2_snapshot_to_gmt */ if (priv->snaps->regex != NULL) { tmpstr = talloc_strdup(talloc_tos(), name); - /* point "name" to the time format */ + /* Point "name" at <delimiter><time_format> */ name = strstr(name, priv->config->delimiter); if (name == NULL) { goto done; } - /* Extract the prefix */ + /* Now point name at <time_format> */ + name = name + strlen(priv->config->delimiter); + /* Locate the the prefix */ tmp = strstr(tmpstr, priv->config->delimiter); if (tmp == NULL) { goto done; } + /* Trim <delimiter><time_format> from tmpstr leaving prefix */ *tmp = '\0'; /* Parse regex */
On Sun, 2017-04-02 at 22:42 +0100, Michael Miller via samba wrote:> Hi > > I could not get a custom "shadow:delimiter" for the vfs shadow_copy2 > module to work successfully for me with Samba 4.6.2. I did not try > previous versions. Based on my testing it seems that an additional line > of code is needed in vfs_shadow_copy2.c as shown in the patch below > (some comment updates are included too for code readability). > > Without the below patch, previous versions were not being returned by > Samba when using a shadow:delimiter. I was using a sample config of > > shadow:snapprefix = ^Snap > shadow:delimiter = _._ > shadow:format = %Y.%m.%d-%H.%M.%S >I think you missed to specify delimiter in format parameter for shadow_copy2 module as below: shadow:format = _._%Y.%m.%d-%H.%M.%S If its still not working, can you please share me the logs(with log level 10) so as to debug the issue?> with sample snapshots named: > Snap_testing1_._2016.11.01-01.00.01 > Snap_prerelease_._2016.12.01-01.00.02 > Snap_postrelease_._2017.01.01-01.00.01 > > Is anyone able to use a custom shadow:delimiter successfully without any > modifications to the Samba code? If not, how do I go about getting this > patch applied? > > > diff -up vfs_shadow_copy2.c.orig vfs_shadow_copy2.c > --- vfs_shadow_copy2.c.orig 2017-03-31 14:53:38.722560396 +0100 > +++ vfs_shadow_copy2.c 2017-04-02 22:13:41.943038415 +0100 > @@ -1866,16 +1866,19 @@ static bool shadow_copy2_snapshot_to_gmt > */ > if (priv->snaps->regex != NULL) { > tmpstr = talloc_strdup(talloc_tos(), name); > - /* point "name" to the time format */ > + /* Point "name" at <delimiter><time_format> */ > name = strstr(name, priv->config->delimiter); > if (name == NULL) { > goto done; > } > - /* Extract the prefix */ > + /* Now point name at <time_format> */ > + name = name + strlen(priv->config->delimiter); > + /* Locate the the prefix */ > tmp = strstr(tmpstr, priv->config->delimiter); > if (tmp == NULL) { > goto done; > } > + /* Trim <delimiter><time_format> from tmpstr leaving > prefix */ > *tmp = '\0'; > > /* Parse regex */ >
Hi Thank you for your reply. It is very much appreciated. I have recompiled the source (without my patch) and when the shadow:delimiter is included within the shadow:format Samba does work as expected. This is consistent with the code which I patched. However - this configuration appears to contradict the man page for vfs_shadow which states: shadow:delimiter This optional parameter is used as a delimiter between shadow:snapprefix and shadow:format. This parameter is used only when shadow:snapprefix is set. It states that the delimiter is the parameter *between* the snapprefix and format. The way it is written, I did not understand it to mean that the delimiter needs to be included within the format parameter. If the wording is considered to be correct (which I don't) then I would suggest that an example is included within the man page which clearly shows the usage of the snapprefix, delimiter and format options when used together. Maybe something like: shadow:snapprefix = ^\(monthly\)\{0,1\}\(daily\)\{0,1\}$ shadow:delimiter = _UTC_ shadow:format = _UTC_%Y.%m.%d-%H.%M.%S as an example which would include the following directories: daily_UTC_2017.02.05-01.00.01 monthly_UTC_2017.02.02-01.00.01 monthly_UTC_2017.02.03-01.00.01 and not weekly_UTC_2017.02.04-01.00.0 Thanks again - your assistance is appreciated as it means I don't need to try and submit a patch or maintain a separate patched version of Samba :) Kind regards, Mike On 19/04/2017 07:14, Anoop C S via samba wrote:> On Sun, 2017-04-02 at 22:42 +0100, Michael Miller via samba wrote: >> Hi >> >> I could not get a custom "shadow:delimiter" for the vfs shadow_copy2 >> module to work successfully for me with Samba 4.6.2. I did not try >> previous versions. Based on my testing it seems that an additional line >> of code is needed in vfs_shadow_copy2.c as shown in the patch below >> (some comment updates are included too for code readability). >> >> Without the below patch, previous versions were not being returned by >> Samba when using a shadow:delimiter. I was using a sample config of >> >> shadow:snapprefix = ^Snap >> shadow:delimiter = _._ >> shadow:format = %Y.%m.%d-%H.%M.%S >> > I think you missed to specify delimiter in format parameter for shadow_copy2 module as below: > > shadow:format = _._%Y.%m.%d-%H.%M.%S > > If its still not working, can you please share me the logs(with log level 10) so as to debug the > issue? > >> with sample snapshots named: >> Snap_testing1_._2016.11.01-01.00.01 >> Snap_prerelease_._2016.12.01-01.00.02 >> Snap_postrelease_._2017.01.01-01.00.01 >> >> Is anyone able to use a custom shadow:delimiter successfully without any >> modifications to the Samba code? If not, how do I go about getting this >> patch applied? >> >> >> diff -up vfs_shadow_copy2.c.orig vfs_shadow_copy2.c >> --- vfs_shadow_copy2.c.orig 2017-03-31 14:53:38.722560396 +0100 >> +++ vfs_shadow_copy2.c 2017-04-02 22:13:41.943038415 +0100 >> @@ -1866,16 +1866,19 @@ static bool shadow_copy2_snapshot_to_gmt >> */ >> if (priv->snaps->regex != NULL) { >> tmpstr = talloc_strdup(talloc_tos(), name); >> - /* point "name" to the time format */ >> + /* Point "name" at <delimiter><time_format> */ >> name = strstr(name, priv->config->delimiter); >> if (name == NULL) { >> goto done; >> } >> - /* Extract the prefix */ >> + /* Now point name at <time_format> */ >> + name = name + strlen(priv->config->delimiter); >> + /* Locate the the prefix */ >> tmp = strstr(tmpstr, priv->config->delimiter); >> if (tmp == NULL) { >> goto done; >> } >> + /* Trim <delimiter><time_format> from tmpstr leaving >> prefix */ >> *tmp = '\0'; >> >> /* Parse regex */ >>
Seemingly Similar Threads
- vfs_shadow_copy2 delimiter not working
- testers needed for CAM INVARIANTS fix
- VB Code to convert BMP to LSS for splash screens
- vfs_shadow_copy2 with snapprefix & delimiter options in samba 4.6.2
- vfs_shadow_copy2 with snapprefix & delimiter options in samba 4.6.2