From: Michael Vrable Date: Tue, 8 Jan 2008 19:50:49 +0000 (-0800) Subject: Add a flag to force a full rewrite of the metadata log in a snapshot. X-Git-Url: http://git.vrable.net/?p=cumulus.git;a=commitdiff_plain;h=8cbb089d5463234be70eb7029e5e0bf050c4f7c5 Add a flag to force a full rewrite of the metadata log in a snapshot. When --full-metadata is given, no pointers to old metadata will be written out. This could be used periodically in backups (say, weekly) to prevent long dependencies in the metadata logs, at least until better cleaning is implemented. --- diff --git a/metadata.cc b/metadata.cc index c27278b..cb3dabb 100644 --- a/metadata.cc +++ b/metadata.cc @@ -24,6 +24,10 @@ using std::ostringstream; static const size_t LBS_METADATA_BLOCK_SIZE = 65536; +// If true, forces a full write of metadata: will not include pointers to +// metadata in old snapshots. +bool flag_full_metadata = false; + /* TODO: Move to header file */ void add_segment(const string& segment); @@ -348,7 +352,7 @@ void MetadataWriter::add(dictionary info) item.reused = false; item.text += encode_dict(info) + "\n"; - if (info == old_metadata) { + if (info == old_metadata && !flag_full_metadata) { ObjectReference ref = ObjectReference::parse(old_metadata_loc); if (!ref.is_null()) { item.reused = true; diff --git a/metadata.h b/metadata.h index 6347080..858a94d 100644 --- a/metadata.h +++ b/metadata.h @@ -21,6 +21,8 @@ #include "ref.h" #include "util.h" +extern bool flag_full_metadata; + /* Metadata for a single inode, ready to be written out. */ struct MetadataItem { int offset; diff --git a/scandir.cc b/scandir.cc index 3a56d9c..7a7ba46 100644 --- a/scandir.cc +++ b/scandir.cc @@ -565,7 +565,8 @@ void usage(const char *program) " program though which to filter descriptor\n" " --scheme=NAME optional name for this snapshot\n" " --intent=FLOAT intended backup type: 1=daily, 7=weekly, ...\n" - " (defaults to \"1\")\n", + " (defaults to \"1\")\n" + " --full-metadata do not re-use metadata from previous backups\n", lbs_version, program ); } @@ -587,6 +588,7 @@ int main(int argc, char *argv[]) {"scheme", 1, 0, 0}, // 5 {"signature-filter", 1, 0, 0}, // 6 {"intent", 1, 0, 0}, // 7 + {"full-metadata", 0, 0, 0}, // 8 {NULL, 0, 0, 0}, }; @@ -627,6 +629,9 @@ int main(int argc, char *argv[]) if (snapshot_intent <= 0) snapshot_intent = 1; break; + case 8: // --full-metadata + flag_full_metadata = true; + break; default: fprintf(stderr, "Unhandled long option!\n"); return 1;