Example #1
0
        private static void Restore(string[] args, Configuration configuration)
        {
            log.Info("restore an inventory");
            if (args.Length < 3 || args.Length > 4)
            {
                log.Error("wrong number of command line args");
                Environment.Exit(-1);
            }

            FileInfo inventoryFile = new FileInfo(args[1]);

            if (!inventoryFile.Exists)
            {
                log.Error("inventory does not exists");
                Environment.Exit(-1);
            }

            DirectoryInfo diTarget = new DirectoryInfo(args[2]);

            log.Info("loading inventory " + inventoryFile.FullName);
            Inventory i = Inventory.FromXml(inventoryFile, configuration);

            log.Info("init storage " + diTarget.FullName);
            ObjectStorage store = new ObjectStorage(inventoryFile.Directory, configuration);

            string partialRestorePath = null;

            if (args.Length == 4 && !string.IsNullOrWhiteSpace(args[3]))
            {
                partialRestorePath = args[3];
            }

            if (partialRestorePath == null)
            {
                log.Info("start restore");
                store.Restore(i, diTarget);
            }
            else
            {
                log.Info("start partial restore: " + partialRestorePath);
                store.PartialRestore(i, diTarget, partialRestorePath);
            }

            log.Info("finished restore");
        }