printf("%s\n", path.c_str());
- file_info["mode"] = encode_int(stat_buf.st_mode & 07777);
+ file_info["mode"] = encode_int(stat_buf.st_mode & 07777, 8);
file_info["mtime"] = encode_int(stat_buf.st_mtime);
file_info["user"] = encode_int(stat_buf.st_uid);
file_info["group"] = encode_int(stat_buf.st_gid);
" (defaults to \"bzip2 -c\")\n"
" --filter-extension=EXT\n"
" string to append to segment files\n"
- " (defaults to \".bz2\")\n",
+ " (defaults to \".bz2\")\n"
+ " --scheme=NAME optional name for this snapshot\n",
program
);
}
string backup_source = ".";
string backup_dest = "";
string localdb_dir = "";
+ string backup_scheme = "";
while (1) {
static struct option long_options[] = {
{"filter", 1, 0, 0}, // 2
{"filter-extension", 1, 0, 0}, // 3
{"dest", 1, 0, 0}, // 4
+ {"scheme", 1, 0, 0}, // 5
{NULL, 0, 0, 0},
};
case 4: // --dest
backup_dest = optarg;
break;
+ case 5: // --scheme
+ backup_scheme = optarg;
+ break;
default:
fprintf(stderr, "Unhandled long option!\n");
return 1;
* snapshot. */
string database_path = localdb_dir + "/localdb.sqlite";
db = new LocalDb;
- db->Open(database_path.c_str(), desc_buf);
+ db->Open(database_path.c_str(), desc_buf,
+ backup_scheme.size() ? backup_scheme.c_str() : NULL);
/* Initialize the stat cache, for skipping over unchanged files. */
statcache = new StatCache;
/* 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. */
- string desc_filename = backup_dest + "/snapshot-" + desc_buf + ".lbs";
+ string desc_filename = backup_dest + "/snapshot-";
+ if (backup_scheme.size() > 0)
+ desc_filename += backup_scheme + "-";
+ desc_filename = desc_filename + desc_buf + ".lbs";
std::ofstream descriptor(desc_filename.c_str());
descriptor << "Format: LBS Snapshot v0.1\n";
descriptor << "Producer: LBS " << lbs_version << "\n";
strftime(desc_buf, sizeof(desc_buf), "%Y-%m-%d %H:%M:%S %z", &time_buf);
descriptor << "Date: " << desc_buf << "\n";
+ if (backup_scheme.size() > 0)
+ descriptor << "Scheme: " << backup_scheme << "\n";
descriptor << "Root: " << backup_root << "\n";
descriptor << "Segments:\n";