Пример #1
0
        private static void AddDestination(AddDestinationOptions opts)
        {
            var    srcdep     = FSCoreSrcDependencies.Load(cwd, new DiskFSInterop());
            var    settings   = srcdep.ReadSettings();
            bool   cache_used = settings.ContainsKey(BackupSetting.cache);
            string bsname     = GetBackupSetName(opts.BSName, srcdep);

            string?password = null;

            if (opts.PromptForPassword)
            {
                password = PasswordPrompt();
            }

            string destination = opts.Destination.Trim();

            if (destination.ToLower() == "backblaze")
            {
                destination = "backblaze";
                if (opts.CloudConfigFile == null)
                {
                    throw new ArgumentException("Cloud config file needed to initialize backblaze backup.");
                }
                CoreDstDependencies.InitializeNew(bsname, false, BackblazeDstInterop.InitializeNew(opts.CloudConfigFile, password), cache_used);
            }
            else
            {
                CoreDstDependencies.InitializeNew(bsname, false, DiskDstFSInterop.InitializeNew(destination, password), cache_used);
            }


            List <string> dstlistings;

            if (settings.ContainsKey(BackupSetting.dests))
            {
                dstlistings = settings[BackupSetting.dests].Split(';', StringSplitOptions.RemoveEmptyEntries).Select(d => d.Trim()).ToList();
            }
            else
            {
                dstlistings = new List <string>();
            }

            List <string[]> dsts_passopts_cc = dstlistings.Select(dl => dl.Split('|')).ToList();

            dsts_passopts_cc.Add(new string[] { destination, password != null ? "p" : "n", opts.CloudConfigFile ?? "" });
            dstlistings = dsts_passopts_cc.Select(dpc => string.Join('|', dpc)).ToList();
            srcdep.WriteSetting(BackupSetting.dests, string.Join(';', dstlistings));
        }
Пример #2
0
        /*
         * int Main(string[] args)
         * {
         *  return CommandLine.Parser.Default.ParseArguments<AddOptions, CommitOptions, CloneOptions>(args)
         *    .MapResult(
         *      (AddOptions opts) => RunAddAndReturnExitCode(opts),
         *      (CommitOptions opts) => RunCommitAndReturnExitCode(opts),
         *      (CloneOptions opts) => RunCloneAndReturnExitCode(opts),
         *      errs => 1);
         * }*/

        private static void Initialize(InitOptions opts)
        {
            try
            {
                ICoreSrcDependencies srcdep = FSCoreSrcDependencies.InitializeNew(opts.BSName, cwd, new DiskFSInterop(), opts.Cache);

                if (opts.Cache != null)
                {
                    var cachedep = CoreDstDependencies.InitializeNew(opts.BSName, true, DiskDstFSInterop.InitializeNew(opts.Cache), false);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }