Thanks David. Looks good, we'll get this incorporated soon.
Bill
On 12/06/05 23:27, David Brown wrote:
The patch below adds an option to xfsdump to set the timestamp that a
backup will happen based on. This can be used to correct a problem that
occurs in files that are touched after making a snapshot volume.
For example:
- make snapshot
- touch a file on r/w volume
- xfsdump the r/o snapshot
- undo the snapshot
The touched file will not be included in the dump, but since the timestamp
for the backup happens after this file was touched, the file will also not
be included in future incrementals. This can be fixed as follows:
- touch /tmp/snapstamp
- make snapshot
- xfsdump -t /tmp/snapstamp ...
- undo snapshot
The '-t' option causes xfsdump to use the timestamp of the named file as
the dump time, rather than the current time.
Thanks,
David Brown
Subject: [PATCH] Add '-t' option to allow dump time to be specified.
---
common/global.c | 29 ++++++++++++++++++++++++++++-
common/main.c | 3 +++
dump/getopt.h | 4 ++--
3 files changed, 33 insertions(+), 3 deletions(-)
applies-to: fac8fc29c114fa28618b82a9f5918ff6b9521f37
102ce75c083379636394ec2851b8f07d0610b515
diff --git a/common/global.c b/common/global.c
index d793175..2e05ef9 100644
--- a/common/global.c
+++ b/common/global.c
@@ -76,6 +76,9 @@ global_hdr_alloc( intgen_t argc, char *a
#endif /* DUMP */
intgen_t rval;
+#ifdef DUMP
+ struct stat64 statbuf;
+#endif /* DUMP */
/* sanity checks
*/
@@ -96,7 +99,8 @@ global_hdr_alloc( intgen_t argc, char *a
ghdrp->gh_version = GLOBAL_HDR_VERSION;
/* fill in the timestamp: all changes made at or after this moment
- * will be included in increments on this base.
+ * will be included in increments on this base. This may be
+ * overridden by the '-t' option.
*/
ghdrp->gh_timestamp = (time32_t) time( 0 );
@@ -190,6 +194,29 @@ global_hdr_alloc( intgen_t argc, char *a
ghdrp->gh_version = GLOBAL_HDR_VERSION_0;
break;
#endif /* EXTATTR */
+ case GETOPT_DUMPTIME:
+ /* Use the timestamp of the specified file, rather
+ * than the current time as the dump time.
+ */
+ if ( ! optarg || optarg[ 0 ] == '-' ) {
+ mlog( MLOG_NORMAL | MLOG_ERROR,
+ _("-%c argument missing\n"),
+ optopt );
+ usage( );
+ return 0;
+ }
+ rval = lstat64( optarg, &statbuf );
+ if ( rval ) {
+ mlog( MLOG_NORMAL | MLOG_ERROR,
+ _("unable to get status of %s: %s\n"),
+ optarg,
+ strerror( errno ));
+ usage( );
+ return 0;
+ }
+ ghdrp->gh_timestamp = statbuf.st_mtime;
+ break;
+
#endif /* DUMP */
}
}
diff --git a/common/main.c b/common/main.c
index 3d0b89e..ee53026 100644
--- a/common/main.c
+++ b/common/main.c
@@ -1102,6 +1102,9 @@ usage( void )
#ifdef REVEAL
ULO(_("(miniroot restrictions)"), GETOPT_MINIROOT );
#endif /* REVEAL */
+#ifdef DUMP
+ ULO(_("<stampfile> (use time of file)"), GETOPT_DUMPTIME );
+#endif /* DUMP */
ULN(_("- (stdin)") );
ULN(_("<destination>") );
#endif /* RESTORE */
diff --git a/dump/getopt.h b/dump/getopt.h
index 0aeaa7d..df3393e 100644
--- a/dump/getopt.h
+++ b/dump/getopt.h
@@ -41,7 +41,7 @@
* facilitating easy changes.
*/
-#define GETOPT_CMDSTRING "ab:c:d:ef:hl:mop:qs:v:z:AB:CEFG:H:I:JL:M:NO:PRSTUVWY:Z"
+#define GETOPT_CMDSTRING "ab:c:d:ef:hl:mop:qs:t:v:z:AB:CEFG:H:I:JL:M:NO:PRSTUVWY:Z"
#define GETOPT_DUMPASOFFLINE 'a' /* dump DMF dualstate files as offline */
#define GETOPT_BLOCKSIZE 'b' /* blocksize for rmt */
@@ -62,7 +62,7 @@
#define GETOPT_QIC 'q' /* option to tell dump it's a QIC tape */
/* 'r' */
#define GETOPT_SUBTREE 's' /* subtree dump (content_inode.c) */
-/* 't' */
+#define GETOPT_DUMPTIME 't' /* use stat of file as dump time. */
/* 'u' */
#define GETOPT_VERBOSITY 'v' /* verbosity level (0 to 4 ) */
/* 'w' */
---
0.99.9j
|