1 /* Cumulus: Efficient Filesystem Backup to the Cloud
2 * Copyright (C) 2006-2009, 2012 The Cumulus Developers
3 * See the AUTHORS file for a list of contributors.
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 /* Main entry point for Cumulus. Contains logic for traversing the filesystem
21 * and constructing a backup. */
34 #include <sys/sysmacros.h>
35 #include <sys/types.h>
57 #include "third_party/sha1.h"
65 /* Version information. This will be filled in by the Makefile. */
66 #ifndef CUMULUS_VERSION
67 #define CUMULUS_VERSION Unknown
69 #define CUMULUS_STRINGIFY(s) CUMULUS_STRINGIFY2(s)
70 #define CUMULUS_STRINGIFY2(s) #s
71 static const char cumulus_version[] = CUMULUS_STRINGIFY(CUMULUS_VERSION);
73 static RemoteStore *remote = NULL;
74 static TarSegmentStore *tss = NULL;
75 static MetadataWriter *metawriter = NULL;
77 /* Buffer for holding a single block of data read from a file. */
78 static const size_t LBS_BLOCK_SIZE = 1024 * 1024;
79 static char *block_buf;
81 /* Local database, which tracks objects written in this and previous
82 * invocations to help in creating incremental snapshots. */
85 /* Snapshot intent: 1=daily, 7=weekly, etc. This is not used directly, but is
86 * stored in the local database and can help guide segment cleaning and
87 * snapshot expiration policies. */
88 double snapshot_intent = 1.0;
90 /* Selection of files to include/exclude in the snapshot. */
91 PathFilterList filter_rules;
93 bool flag_rebuild_statcache = false;
95 /* Whether verbose output is enabled. */
98 /* Attempts to open a regular file read-only, but with safety checks for files
99 * that might not be fully trusted. */
100 int safe_open(const string& path, struct stat *stat_buf)
104 /* Be paranoid when opening the file. We have no guarantee that the
105 * file was not replaced between the stat() call above and the open()
106 * call below, so we might not even be opening a regular file. We
107 * supply flags to open to to guard against various conditions before
108 * we can perform an lstat to check that the file is still a regular
110 * - O_NOFOLLOW: in the event the file was replaced by a symlink
111 * - O_NONBLOCK: prevents open() from blocking if the file was
113 * We also add in O_NOATIME, since this may reduce disk writes (for
114 * inode updates). However, O_NOATIME may result in EPERM, so if the
115 * initial open fails, try again without O_NOATIME. */
116 fd = open(path.c_str(), O_RDONLY|O_NOATIME|O_NOFOLLOW|O_NONBLOCK);
118 fd = open(path.c_str(), O_RDONLY|O_NOFOLLOW|O_NONBLOCK);
121 fprintf(stderr, "Unable to open file %s: %m\n", path.c_str());
125 /* Drop the use of the O_NONBLOCK flag; we only wanted that for file
127 long flags = fcntl(fd, F_GETFL);
128 fcntl(fd, F_SETFL, flags & ~O_NONBLOCK);
130 /* Re-check file attributes, storing them into stat_buf if that is
132 struct stat internal_stat_buf;
133 if (stat_buf == NULL)
134 stat_buf = &internal_stat_buf;
136 /* Perform the stat call again, and check that we still have a regular
138 if (fstat(fd, stat_buf) < 0) {
139 fprintf(stderr, "fstat: %m\n");
144 if ((stat_buf->st_mode & S_IFMT) != S_IFREG) {
145 fprintf(stderr, "file is no longer a regular file!\n");
153 /* Read data from a file descriptor and return the amount of data read. A
154 * short read (less than the requested size) will only occur if end-of-file is
156 ssize_t file_read(int fd, char *buf, size_t maxlen)
158 size_t bytes_read = 0;
161 ssize_t res = read(fd, buf, maxlen);
165 fprintf(stderr, "error reading file: %m\n");
167 } else if (res == 0) {
179 /* Read the contents of a file (specified by an open file descriptor) and copy
180 * the data to the store. Returns the size of the file (number of bytes
181 * dumped), or -1 on error. */
182 int64_t dumpfile(int fd, dictionary &file_info, const string &path,
183 struct stat& stat_buf)
186 list<string> object_list;
187 const char *status = NULL; /* Status indicator printed out */
189 /* Look up this file in the old stat cache, if we can. If the stat
190 * information indicates that the file has not changed, do not bother
191 * re-reading the entire contents. Even if the information has been
192 * changed, we can use the list of old blocks in the search for a sub-block
193 * incremental representation. */
195 list<ObjectReference> old_blocks;
197 bool found = metawriter->find(path);
199 old_blocks = metawriter->get_blocks();
202 && !flag_rebuild_statcache
203 && metawriter->is_unchanged(&stat_buf)) {
206 /* If any of the blocks in the object have been expired, then we should
207 * fall back to fully reading in the file. */
208 for (list<ObjectReference>::const_iterator i = old_blocks.begin();
209 i != old_blocks.end(); ++i) {
210 const ObjectReference &ref = *i;
211 if (!db->IsAvailable(ref)) {
218 /* If everything looks okay, use the cached information */
220 file_info["checksum"] = metawriter->get_checksum();
221 for (list<ObjectReference>::const_iterator i = old_blocks.begin();
222 i != old_blocks.end(); ++i) {
223 const ObjectReference &ref = *i;
224 object_list.push_back(ref.to_string());
227 size = stat_buf.st_size;
231 /* If the file is new or changed, we must read in the contents a block at a
234 Hash *hash = Hash::New();
236 subfile.load_old_blocks(old_blocks);
239 ssize_t bytes = file_read(fd, block_buf, LBS_BLOCK_SIZE);
243 fprintf(stderr, "Backup contents for %s may be incorrect\n",
248 hash->update(block_buf, bytes);
250 // Sparse file processing: if we read a block of all zeroes, encode
252 bool all_zero = true;
253 for (int i = 0; i < bytes; i++) {
254 if (block_buf[i] != 0) {
260 // Either find a copy of this block in an already-existing segment,
261 // or index it so it can be re-used in the future
262 double block_age = 0.0;
265 Hash *hash = Hash::New();
266 hash->update(block_buf, bytes);
267 string block_csum = hash->digest_str();
271 ref = ObjectReference(ObjectReference::REF_ZERO);
272 ref.set_range(0, bytes);
274 ref = db->FindObject(block_csum, bytes);
277 list<ObjectReference> refs;
279 // Store a copy of the object if one does not yet exist
281 LbsObject *o = new LbsObject;
284 /* We might still have seen this checksum before, if the object
285 * was stored at some time in the past, but we have decided to
286 * clean the segment the object was originally stored in
287 * (FindObject will not return such objects). When rewriting
288 * the object contents, put it in a separate group, so that old
289 * objects get grouped together. The hope is that these old
290 * objects will continue to be used in the future, and we
291 * obtain segments which will continue to be well-utilized.
292 * Additionally, keep track of the age of the data by looking
293 * up the age of the block which was expired and using that
294 * instead of the current time. */
295 if (db->IsOldObject(block_csum, bytes,
296 &block_age, &object_group)) {
297 if (object_group == 0) {
298 o->set_group("data");
301 sprintf(group, "compacted-%d", object_group);
307 o->set_group("data");
311 subfile.analyze_new_block(block_buf, bytes);
312 refs = subfile.create_incremental(tss, o, block_age);
314 if (flag_rebuild_statcache && ref.is_normal()) {
315 subfile.analyze_new_block(block_buf, bytes);
316 subfile.store_analyzed_signatures(ref);
321 while (!refs.empty()) {
322 ref = refs.front(); refs.pop_front();
323 object_list.push_back(ref.to_string());
332 file_info["checksum"] = hash->digest_str();
336 // Sanity check: if we are rebuilding the statcache, but the file looks
337 // like it hasn't changed, then the newly-computed checksum should match
338 // the checksum in the statcache. If not, we have possible disk corruption
339 // and report a warning.
340 if (flag_rebuild_statcache) {
342 && metawriter->is_unchanged(&stat_buf)
343 && file_info["checksum"] != metawriter->get_checksum()) {
345 "Warning: Checksum for %s does not match expected value\n"
349 metawriter->get_checksum().c_str(),
350 file_info["checksum"].c_str());
354 if (verbose && status != NULL)
355 printf(" [%s]\n", status);
357 string blocklist = "";
358 for (list<string>::iterator i = object_list.begin();
359 i != object_list.end(); ++i) {
360 if (i != object_list.begin())
364 file_info["data"] = blocklist;
369 /* Look up a user/group and convert it to string form (either strictly numeric
370 * or numeric plus symbolic). Caches the results of the call to
371 * getpwuid/getgrgid. */
372 string user_to_string(uid_t uid) {
373 static map<uid_t, string> user_cache;
374 map<uid_t, string>::const_iterator i = user_cache.find(uid);
375 if (i != user_cache.end())
378 string result = encode_int(uid);
379 struct passwd *pwd = getpwuid(uid);
380 if (pwd != NULL && pwd->pw_name != NULL) {
381 result += " (" + uri_encode(pwd->pw_name) + ")";
383 user_cache[uid] = result;
387 string group_to_string(gid_t gid) {
388 static map<gid_t, string> group_cache;
389 map<gid_t, string>::const_iterator i = group_cache.find(gid);
390 if (i != group_cache.end())
393 string result = encode_int(gid);
394 struct group *grp = getgrgid(gid);
395 if (grp != NULL && grp->gr_name != NULL) {
396 result += " (" + uri_encode(grp->gr_name) + ")";
398 group_cache[gid] = result;
402 /* Dump a specified filesystem object (file, directory, etc.) based on its
403 * inode information. If the object is a regular file, an open filehandle is
405 void dump_inode(const string& path, // Path within snapshot
406 const string& fullpath, // Path to object in filesystem
407 struct stat& stat_buf, // Results of stat() call
408 int fd) // Open filehandle if regular file
411 dictionary file_info;
416 printf("%s\n", path.c_str());
417 metawriter->find(path);
419 file_info["name"] = uri_encode(path);
420 file_info["mode"] = encode_int(stat_buf.st_mode & 07777, 8);
421 file_info["ctime"] = encode_int(stat_buf.st_ctime);
422 file_info["mtime"] = encode_int(stat_buf.st_mtime);
423 file_info["user"] = user_to_string(stat_buf.st_uid);
424 file_info["group"] = group_to_string(stat_buf.st_gid);
426 time_t now = time(NULL);
427 if (now - stat_buf.st_ctime < 30 || now - stat_buf.st_mtime < 30)
428 if ((stat_buf.st_mode & S_IFMT) != S_IFDIR)
429 file_info["volatile"] = "1";
431 if (stat_buf.st_nlink > 1 && (stat_buf.st_mode & S_IFMT) != S_IFDIR) {
432 file_info["links"] = encode_int(stat_buf.st_nlink);
435 file_info["inode"] = encode_int(major(stat_buf.st_dev))
436 + "/" + encode_int(minor(stat_buf.st_dev))
437 + "/" + encode_int(stat_buf.st_ino);
441 switch (stat_buf.st_mode & S_IFMT) {
450 inode_type = ((stat_buf.st_mode & S_IFMT) == S_IFBLK) ? 'b' : 'c';
451 file_info["device"] = encode_int(major(stat_buf.st_rdev))
452 + "/" + encode_int(minor(stat_buf.st_rdev));
457 /* Use the reported file size to allocate a buffer large enough to read
458 * the symlink. Allocate slightly more space, so that we ask for more
459 * bytes than we expect and so check for truncation. */
460 buf = new char[stat_buf.st_size + 2];
461 len = readlink(fullpath.c_str(), buf, stat_buf.st_size + 1);
463 fprintf(stderr, "error reading symlink: %m\n");
464 } else if (len <= stat_buf.st_size) {
466 file_info["target"] = uri_encode(buf);
467 } else if (len > stat_buf.st_size) {
468 fprintf(stderr, "error reading symlink: name truncated\n");
476 file_size = dumpfile(fd, file_info, path, stat_buf);
477 file_info["size"] = encode_int(file_size);
480 return; // error occurred; do not dump file
482 if (file_size != stat_buf.st_size) {
483 fprintf(stderr, "Warning: Size of %s changed during reading\n",
485 file_info["volatile"] = "1";
494 fprintf(stderr, "Unknown inode type: mode=%x\n", stat_buf.st_mode);
498 file_info["type"] = string(1, inode_type);
500 metawriter->add(file_info);
503 /* Converts a path to the normalized form used in the metadata log. Paths are
504 * written as relative (without any leading slashes). The root directory is
505 * referred to as ".". */
506 string metafile_path(const string& path)
508 const char *newpath = path.c_str();
511 if (*newpath == '\0')
516 void try_merge_filter(const string& path, const string& basedir)
518 struct stat stat_buf;
519 if (lstat(path.c_str(), &stat_buf) < 0)
521 if ((stat_buf.st_mode & S_IFMT) != S_IFREG)
523 int fd = safe_open(path, NULL);
527 /* As a very crude limit on the complexity of merge rules, only read up to
528 * one block (1 MB) worth of data. If the file doesn't seems like it might
529 * be larger than that, don't parse the rules in it. */
530 ssize_t bytes = file_read(fd, block_buf, LBS_BLOCK_SIZE);
532 if (bytes < 0 || bytes >= static_cast<ssize_t>(LBS_BLOCK_SIZE - 1)) {
533 /* TODO: Add more strict resource limits on merge files? */
535 "Unable to read filter merge file (possibly size too large\n");
538 filter_rules.merge_patterns(metafile_path(path), basedir,
539 string(block_buf, bytes));
542 void scanfile(const string& path)
545 struct stat stat_buf;
548 string output_path = metafile_path(path);
550 if (lstat(path.c_str(), &stat_buf) < 0) {
551 fprintf(stderr, "lstat(%s): %m\n", path.c_str());
555 bool is_directory = ((stat_buf.st_mode & S_IFMT) == S_IFDIR);
556 if (!filter_rules.is_included(output_path, is_directory))
559 if ((stat_buf.st_mode & S_IFMT) == S_IFREG) {
560 fd = safe_open(path, &stat_buf);
565 dump_inode(output_path, path, stat_buf, fd);
570 /* If we hit a directory, now that we've written the directory itself,
571 * recursively scan the directory. */
573 DIR *dir = opendir(path.c_str());
576 fprintf(stderr, "Error reading directory %s: %m\n",
582 vector<string> contents;
583 while ((ent = readdir(dir)) != NULL) {
584 string filename(ent->d_name);
585 if (filename == "." || filename == "..")
587 contents.push_back(filename);
592 sort(contents.begin(), contents.end());
596 /* First pass through the directory items: look for any filter rules to
597 * merge and do so. */
598 for (vector<string>::iterator i = contents.begin();
599 i != contents.end(); ++i) {
603 else if (path == "/")
606 filename = path + "/" + *i;
607 if (filter_rules.is_mergefile(metafile_path(filename))) {
609 printf("Merging directory filter rules %s\n",
612 try_merge_filter(filename, output_path);
616 /* Second pass: recursively scan all items in the directory for backup;
617 * scanfile() will check if the item should be included or not. */
618 for (vector<string>::iterator i = contents.begin();
619 i != contents.end(); ++i) {
620 const string& filename = *i;
623 else if (path == "/")
624 scanfile("/" + filename);
626 scanfile(path + "/" + filename);
629 filter_rules.restore();
633 void usage(const char *program)
638 "Usage: %s [OPTION]... --dest=DEST PATHS...\n"
639 "Produce backup snapshot of files in SOURCE and store to DEST.\n"
642 " --dest=PATH path where backup is to be written\n"
643 " --upload-script=COMMAND\n"
644 " program to invoke for each backup file generated\n"
645 " --exclude=PATTERN exclude files matching PATTERN from snapshot\n"
646 " --include=PATTERN include files matching PATTERN in snapshot\n"
647 " --dir-merge=PATTERN parse files matching PATTERN to read additional\n"
648 " subtree-specific include/exclude rules during backup\n"
649 " --localdb=PATH local backup metadata is stored in PATH\n"
650 " --tmpdir=PATH path for temporarily storing backup files\n"
651 " (defaults to TMPDIR environment variable or /tmp)\n"
652 " --filter=COMMAND program through which to filter segment data\n"
653 " (defaults to \"bzip2 -c\")\n"
654 " --filter-extension=EXT\n"
655 " string to append to segment files\n"
656 " (defaults to \".bz2\")\n"
657 " --signature-filter=COMMAND\n"
658 " program though which to filter descriptor\n"
659 " --scheme=NAME optional name for this snapshot\n"
660 " --intent=FLOAT intended backup type: 1=daily, 7=weekly, ...\n"
661 " (defaults to \"1\")\n"
662 " --full-metadata do not re-use metadata from previous backups\n"
663 " --rebuild-statcache re-read all file data to verify statcache\n"
664 " -v --verbose list files as they are backed up\n"
666 "Exactly one of --dest or --upload-script must be specified.\n",
667 cumulus_version, program
671 int main(int argc, char *argv[])
675 string backup_dest = "", backup_script = "";
676 string localdb_dir = "";
677 string backup_scheme = "";
678 string signature_filter = "";
680 string tmp_dir = "/tmp";
681 if (getenv("TMPDIR") != NULL)
682 tmp_dir = getenv("TMPDIR");
685 static struct option long_options[] = {
686 {"localdb", 1, 0, 0}, // 0
687 {"filter", 1, 0, 0}, // 1
688 {"filter-extension", 1, 0, 0}, // 2
689 {"dest", 1, 0, 0}, // 3
690 {"scheme", 1, 0, 0}, // 4
691 {"signature-filter", 1, 0, 0}, // 5
692 {"intent", 1, 0, 0}, // 6
693 {"full-metadata", 0, 0, 0}, // 7
694 {"tmpdir", 1, 0, 0}, // 8
695 {"upload-script", 1, 0, 0}, // 9
696 {"rebuild-statcache", 0, 0, 0}, // 10
697 {"include", 1, 0, 0}, // 11
698 {"exclude", 1, 0, 0}, // 12
699 {"dir-merge", 1, 0, 0}, // 13
700 // Aliases for short options
701 {"verbose", 0, 0, 'v'},
706 int c = getopt_long(argc, argv, "v", long_options, &long_index);
712 switch (long_index) {
714 localdb_dir = optarg;
717 filter_program = optarg;
719 case 2: // --filter-extension
720 filter_extension = optarg;
723 backup_dest = optarg;
726 backup_scheme = optarg;
728 case 5: // --signature-filter
729 signature_filter = optarg;
732 snapshot_intent = atof(optarg);
733 if (snapshot_intent <= 0)
736 case 7: // --full-metadata
737 flag_full_metadata = true;
742 case 9: // --upload-script
743 backup_script = optarg;
745 case 10: // --rebuild-statcache
746 flag_rebuild_statcache = true;
748 case 11: // --include
749 filter_rules.add_pattern(PathFilterList::INCLUDE, optarg, "");
751 case 12: // --exclude
752 filter_rules.add_pattern(PathFilterList::EXCLUDE, optarg, "");
754 case 13: // --dir-merge
755 filter_rules.add_pattern(PathFilterList::DIRMERGE, optarg, "");
758 fprintf(stderr, "Unhandled long option!\n");
773 if (optind == argc) {
778 if (backup_dest == "" && backup_script == "") {
780 "Error: Backup destination must be specified using --dest= or --upload-script=\n");
785 if (backup_dest != "" && backup_script != "") {
787 "Error: Cannot specify both --dest= and --upload-script=\n");
792 // Default for --localdb is the same as --dest
793 if (localdb_dir == "") {
794 localdb_dir = backup_dest;
796 if (localdb_dir == "") {
798 "Error: Must specify local database path with --localdb=\n");
803 block_buf = new char[LBS_BLOCK_SIZE];
805 /* Initialize the remote storage layer. If using an upload script, create
806 * a temporary directory for staging files. Otherwise, write backups
807 * directly to the destination directory. */
808 if (backup_script != "") {
809 tmp_dir = tmp_dir + "/lbs." + generate_uuid();
810 if (mkdir(tmp_dir.c_str(), 0700) < 0) {
811 fprintf(stderr, "Cannot create temporary directory %s: %m\n",
815 remote = new RemoteStore(tmp_dir, backup_script=backup_script);
817 remote = new RemoteStore(backup_dest);
820 /* Store the time when the backup started, so it can be included in the
823 struct tm time_buf_local, time_buf_utc;
826 localtime_r(&now, &time_buf_local);
827 gmtime_r(&now, &time_buf_utc);
828 strftime(desc_buf, sizeof(desc_buf), "%Y%m%dT%H%M%S", &time_buf_utc);
830 /* Open the local database which tracks all objects that are stored
831 * remotely, for efficient incrementals. Provide it with the name of this
833 string database_path = localdb_dir + "/localdb.sqlite";
835 db->Open(database_path.c_str(), desc_buf, backup_scheme.c_str(),
838 tss = new TarSegmentStore(remote, db);
840 /* Initialize the stat cache, for skipping over unchanged files. */
841 metawriter = new MetadataWriter(tss, localdb_dir.c_str(), desc_buf,
842 backup_scheme.c_str());
844 for (int i = optind; i < argc; i++) {
848 ObjectReference root_ref = metawriter->close();
849 string backup_root = root_ref.to_string();
857 /* Write out a checksums file which lists the checksums for all the
858 * segments included in this snapshot. The format is designed so that it
859 * may be easily verified using the sha1sums command. */
860 const char csum_type[] = "sha1";
861 string checksum_filename = "snapshot-";
862 if (backup_scheme.size() > 0)
863 checksum_filename += backup_scheme + "-";
864 checksum_filename = checksum_filename + desc_buf + "." + csum_type + "sums";
865 RemoteFile *checksum_file = remote->alloc_file(checksum_filename,
867 FILE *checksums = fdopen(checksum_file->get_fd(), "w");
869 std::set<string> segment_list = db->GetUsedSegments();
870 for (std::set<string>::iterator i = segment_list.begin();
871 i != segment_list.end(); ++i) {
872 string seg_path, seg_csum;
873 if (db->GetSegmentChecksum(*i, &seg_path, &seg_csum)) {
874 const char *raw_checksum = NULL;
875 if (strncmp(seg_csum.c_str(), csum_type,
876 strlen(csum_type)) == 0) {
877 raw_checksum = seg_csum.c_str() + strlen(csum_type);
878 if (*raw_checksum == '=')
884 if (raw_checksum != NULL)
885 fprintf(checksums, "%s *%s\n",
886 raw_checksum, seg_path.c_str());
891 SHA1Checksum checksum_csum;
893 checksum_filename = checksum_file->get_local_path();
894 if (checksum_csum.process_file(checksum_filename.c_str())) {
895 csum = checksum_csum.checksum_str();
898 checksum_file->send();
902 /* All other files should be flushed to remote storage before writing the
903 * backup descriptor below, so that it is not possible to have a backup
904 * descriptor written out depending on non-existent (not yet written)
908 /* Write a backup descriptor file, which says which segments are needed and
909 * where to start to restore this snapshot. The filename is based on the
910 * current time. If a signature filter program was specified, filter the
911 * data through that to give a chance to sign the descriptor contents. */
912 string desc_filename = "snapshot-";
913 if (backup_scheme.size() > 0)
914 desc_filename += backup_scheme + "-";
915 desc_filename = desc_filename + desc_buf + ".lbs";
917 RemoteFile *descriptor_file = remote->alloc_file(desc_filename,
919 int descriptor_fd = descriptor_file->get_fd();
920 if (descriptor_fd < 0) {
921 fprintf(stderr, "Unable to open descriptor output file: %m\n");
924 pid_t signature_pid = 0;
925 if (signature_filter.size() > 0) {
926 int new_fd = spawn_filter(descriptor_fd, signature_filter.c_str(),
928 close(descriptor_fd);
929 descriptor_fd = new_fd;
931 FILE *descriptor = fdopen(descriptor_fd, "w");
933 fprintf(descriptor, "Format: Cumulus Snapshot v0.11\n");
934 fprintf(descriptor, "Producer: Cumulus %s\n", cumulus_version);
935 strftime(desc_buf, sizeof(desc_buf), "%Y-%m-%d %H:%M:%S %z",
937 fprintf(descriptor, "Date: %s\n", desc_buf);
938 if (backup_scheme.size() > 0)
939 fprintf(descriptor, "Scheme: %s\n", backup_scheme.c_str());
940 fprintf(descriptor, "Backup-Intent: %g\n", snapshot_intent);
941 fprintf(descriptor, "Root: %s\n", backup_root.c_str());
943 if (csum.size() > 0) {
944 fprintf(descriptor, "Checksums: %s\n", csum.c_str());
947 fprintf(descriptor, "Segments:\n");
948 for (std::set<string>::iterator i = segment_list.begin();
949 i != segment_list.end(); ++i) {
950 fprintf(descriptor, " %s\n", i->c_str());
957 waitpid(signature_pid, &status, 0);
959 if (!WIFEXITED(status) || WEXITSTATUS(status) != 0) {
960 fatal("Signature filter process error");
964 descriptor_file->send();
969 if (backup_script != "") {
970 if (rmdir(tmp_dir.c_str()) < 0) {
972 "Warning: Cannot delete temporary directory %s: %m\n",