25 if ((type ==
"cvmfs") || (type ==
"posix"))
return true;
31 if (!CheckType(src_type) || !CheckType(dst_type))
return false;
37 if (dst_data_dir.empty())
38 dst_data_dir = dst_base_dir +
"/.data";
40 if (spec_trace_path.empty())
41 spec_trace_path = repo_name +
".spec";
50 , src_base_dir(
"/cvmfs")
51 , src_config_path(
"cvmfs.conf:cvmfs.local")
55 , dst_base_dir(
"/export/cvmfs")
60 , do_garbage_collection(false)
80 "CernVM File System Shrinkwrapper, version %s\n\n"
81 "This tool takes a cvmfs repository and outputs\n"
82 "to a destination files system.\n"
83 "Usage: cvmfs_shrinkwrap "
84 "[-r][-sbcf][-dxyz][-t][-jrg]\n"
86 " -r --repo Repository name [required]\n"
87 " -s --src-type Source filesystem type [default:cvmfs]\n"
88 " -b --src-base Source base location [default:/cvmfs/]\n"
89 " -c --src-cache Source cache\n"
90 " -f --src-config Source config [default:cvmfs.conf:cvmfs.local]\n"
91 " -d --dest-type Dest filesystem type [default:posix]\n"
92 " -x --dest-base Dest base [default:/export/cvmfs]\n"
93 " -y --dest-cache Dest cache [default:$BASE/.data]\n"
94 " -z --dest-config Dest config\n"
95 " -t --spec-file Specification file [default=$REPO.spec]\n"
96 " -j --threads Number of concurrent copy threads [default:2*CPUs]\n"
97 " -p --stat-period Frequency of stat prints, 0 disables [default:10]\n"
98 " -g --gc Perform garbage collection on destination\n",
104 int main(
int argc,
char **argv) {
108 static struct option long_opts[] = {
110 {
"help", no_argument, 0,
'h'},
111 {
"repo", required_argument, 0,
'r'},
112 {
"src-type", required_argument, 0,
's'},
113 {
"src-base", required_argument, 0,
'b'},
114 {
"src-cache", required_argument, 0,
'c'},
115 {
"src-config", required_argument, 0,
'f'},
116 {
"dest-type", required_argument, 0,
'd'},
117 {
"dest-base", required_argument, 0,
'x'},
118 {
"dest-cache", required_argument, 0,
'y'},
119 {
"dest-config", required_argument, 0,
'z'},
120 {
"spec-file", required_argument, 0,
't'},
121 {
"threads", required_argument, 0,
'j'},
122 {
"stat-period", required_argument, 0,
'p'},
123 {
"gc", no_argument, 0,
'g'},
127 static const char short_opts[] =
"hb:s:r:c:f:d:x:y:t:j:p:g";
129 while ((c = getopt_long(argc, argv, short_opts, long_opts, NULL)) >= 0) {
135 params.repo_name = optarg;
138 params.src_type = optarg;
141 params.src_base_dir = optarg;
144 params.src_data_dir = optarg;
147 params.src_config_path = optarg;
150 params.dst_type = optarg;
153 params.dst_base_dir = optarg;
156 params.dst_data_dir = optarg;
159 params.dst_config_path = optarg;
162 params.spec_trace_path = optarg;
167 "Invalid value passed to 'j': %s : only non-negative integers",
174 params.do_garbage_collection =
true;
179 "Invalid value passed to 'p': %s : only non-negative integers",
192 if (!params.Check())
return 1;
200 params.repo_name.c_str(),
201 params.src_base_dir.c_str(),
202 params.src_data_dir.c_str(),
203 params.src_config_path.c_str(),
204 params.num_parallel);
216 params.repo_name.c_str(),
217 params.dst_base_dir.c_str(),
218 params.dst_data_dir.c_str(),
219 params.dst_config_path.c_str(),
220 params.num_parallel);
234 params.spec_trace_path.c_str(),
239 if (params.do_garbage_collection) {
std::string dst_config_path
bool do_garbage_collection
struct fs_traversal * FindInterface(const char *type)
unsigned int GetNumberOfCpuCores()
bool CheckType(const std::string &type)
std::string src_config_path
bool String2Uint64Parse(const std::string &value, uint64_t *result)
int SyncInit(struct fs_traversal *src, struct fs_traversal *dest, const char *base, const char *spec, uint64_t parallel, uint64_t stat_period)
void(* finalize)(struct fs_traversal_context *ctx)
struct fs_traversal_context *(* initialize)(const char *repo, const char *base, const char *data, const char *config, int num_threads)
void(* archive_provenance)(struct fs_traversal_context *src, struct fs_traversal_context *dest)
int GarbageCollect(struct fs_traversal *fs)
std::string spec_trace_path
struct fs_traversal_context * context_
CVMFS_EXPORT void LogCvmfs(const LogSource source, const int mask, const char *format,...)