The backup descriptor names the object at the root of the snapshot, and
lists all the segments needed. The filename used is currently fixed,
though, and should later be based on the current time.
#include <list>
#include <vector>
#include <iostream>
#include <list>
#include <vector>
#include <iostream>
#include <sstream>
#include <set>
#include <sstream>
#include <set>
{
block_buf = new char[LBS_BLOCK_SIZE];
{
block_buf = new char[LBS_BLOCK_SIZE];
- if (argc > 1) {
- tss = new TarSegmentStore(argv[1]);
- } else {
- tss = new TarSegmentStore(".");
- }
+ string backup_dest = ".";
+
+ if (argc > 1)
+ backup_dest = argv[1];
+
+ tss = new TarSegmentStore(backup_dest);
+
+ string desc_filename = backup_dest + "/snapshot.lbs";
+ std::ofstream descriptor(desc_filename.c_str());
root->checksum();
segment_list.insert(root->get_ref().get_segment());
root->checksum();
segment_list.insert(root->get_ref().get_segment());
- string r = root->get_ref().to_string();
- printf("\nroot: %s\n\n", r.c_str());
+ descriptor << "root: " << root->get_ref().to_string() << "\n\n";
+
+ descriptor << "segments:\n";
for (std::set<string>::iterator i = segment_list.begin();
i != segment_list.end(); ++i) {
for (std::set<string>::iterator i = segment_list.begin();
i != segment_list.end(); ++i) {
- printf(" %s\n", i->c_str());
+ descriptor << " " << *i << "\n";