From: Michael Vrable Date: Wed, 27 Jun 2007 20:20:39 +0000 (-0700) Subject: Write the backup descriptor as the very last step in a backup. X-Git-Url: http://git.vrable.net/?p=cumulus.git;a=commitdiff_plain;h=e392d943a0bca2f12186321ae1658b739a5a5dd4 Write the backup descriptor as the very last step in a backup. For consistency, we should make sure that all segments and other data needed to reconstruct a backup are written before we write out the backup descriptor file itself. --- diff --git a/scandir.cc b/scandir.cc index 71fba9d..c48107a 100644 --- a/scandir.cc +++ b/scandir.cc @@ -504,6 +504,17 @@ int main(int argc, char *argv[]) root->checksum(); segment_list.insert(root->get_ref().get_segment()); + string backup_root = root->get_ref().to_string(); + delete root; + + db->Close(); + + statcache->Close(); + delete statcache; + + tss->sync(); + delete tss; + /* Write a backup descriptor file, which says which segments are needed and * where to start to restore this snapshot. The filename is based on the * current time. */ @@ -513,9 +524,7 @@ int main(int argc, char *argv[]) descriptor << "Format: LBS Snapshot v0.1\n"; strftime(desc_buf, sizeof(desc_buf), "%Y-%m-%d %H:%M:%S %z", &time_buf); descriptor << "Date: " << desc_buf << "\n"; - descriptor << "Root: " << root->get_ref().to_string() << "\n"; - - delete root; + descriptor << "Root: " << backup_root << "\n"; descriptor << "Segments:\n"; for (std::set::iterator i = segment_list.begin(); @@ -523,13 +532,5 @@ int main(int argc, char *argv[]) descriptor << " " << *i << "\n"; } - db->Close(); - - statcache->Close(); - delete statcache; - - tss->sync(); - delete tss; - return 0; }