int sdirs_create_real_working(struct sdirs *sdirs, struct conf *conf) { char tstmp[64]=""; if(timestamp_get_new(sdirs, tstmp, sizeof(tstmp), conf) || free_prepend_s(&sdirs->rworking, sdirs->client, tstmp) || free_prepend_s(&sdirs->treepath, sdirs->rworking, DATA_DIR "/" TREE_DIR)) return -1; // Add the working symlink before creating the directory. // This is because bedup checks the working symlink before // going into a directory. If the directory got created first, // bedup might go into it in the moment before the symlink // gets added. if(symlink(tstmp, sdirs->working)) // relative link to the real work dir { logp("could not point working symlink to: %s\n", sdirs->rworking); return -1; } if(mkdir(sdirs->rworking, 0777)) { logp("could not mkdir for next backup: %s\n", sdirs->rworking); unlink(sdirs->working); return -1; } if(timestamp_write(sdirs->timestamp, tstmp)) { logp("unable to write timestamp %s\n", sdirs->timestamp); return -1; } return 0; }
int datapoint_write(datapoint_t* p, int fd) { if ((timestamp_write(p->t, fd) != 0) || (value_write(p->v, fd) != 0)) return -1; return 0; }
static void do_build_storage_dirs(struct sdirs *sdirs, struct sd *s, int len, int compressed_logs) { int i=0; time_t t=0; char backup[128]=""; char timestamp_path[128]=""; fail_unless(!build_path_w(sdirs->client)); fail_unless(!mkdir(sdirs->client, 0777)); for(i=0; i<len; i++) { snprintf(backup, sizeof(backup), "%s/%s", sdirs->client, s[i].timestamp); snprintf(timestamp_path, sizeof(timestamp_path), "%s/timestamp", backup); fail_unless(!mkdir(backup, 0777)); fail_unless(!timestamp_write(timestamp_path, s[i].timestamp)); if(s[i].flags & BU_CURRENT) fail_unless(!symlink(s[i].timestamp, sdirs->current)); if(s[i].flags & BU_WORKING) fail_unless(!symlink(s[i].timestamp, sdirs->working)); if(s[i].flags & BU_FINISHING) fail_unless(!symlink(s[i].timestamp, sdirs->finishing)); if(s[i].flags & BU_MANIFEST) create_file(backup, "manifest", compressed_logs); if(s[i].flags & BU_LOG_BACKUP) create_file(backup, "log", compressed_logs); if(s[i].flags & BU_LOG_RESTORE) create_file(backup, "restorelog", compressed_logs); if(s[i].flags & BU_LOG_VERIFY) create_file(backup, "verifylog", compressed_logs); if(sdirs->protocol==PROTO_1) { if(s[i].flags & BU_HARDLINKED) create_file(backup, "hardlinked", 0); } // This one is never compressed. if(sdirs->global_sparse) build_file(sdirs->global_sparse, NULL); t+=60*60*24; // Add one day. } }