예제 #1
0
 def test_rm_rf(self):
     tmp_foo = os.path.join(self.temp_dir, 'foo')
     tmp_foo_bar = os.path.join(self.temp_dir, 'foo', 'bar')
     tmp_foo_bar_rules = os.path.join(self.temp_dir, 'foo', 'bar', 'rules')
     os.mkdir(tmp_foo)
     os.mkdir(tmp_foo_bar)
     os.mkdir(tmp_foo_bar_rules)
     rm_rf(tmp_foo)
     ok_(not os.path.exists(tmp_foo))
     ok_(not os.path.exists(tmp_foo_bar))
     ok_(not os.path.exists(tmp_foo_bar_rules))
예제 #2
0
 def test_rm_rf(self):
     tmp_foo = os.path.join(self.temp_dir, 'foo')
     tmp_foo_bar = os.path.join(self.temp_dir, 'foo', 'bar')
     tmp_foo_bar_rules = os.path.join(self.temp_dir, 'foo', 'bar', 'rules')
     os.mkdir(tmp_foo)
     os.mkdir(tmp_foo_bar)
     os.mkdir(tmp_foo_bar_rules)
     rm_rf(tmp_foo)
     ok_(not os.path.exists(tmp_foo))
     ok_(not os.path.exists(tmp_foo_bar))
     ok_(not os.path.exists(tmp_foo_bar_rules))
예제 #3
0
def backup(args):

    if args.repos:

        provider = get_provider_from_config(args.config)

        today = datetime.datetime.now().date()
        abs_date_dir = get_abs_date_dir(args.archive_dir, today)

        mkdir_p(args.staging_dir)
        mkdir_p(args.archive_dir)
        mkdir_p(abs_date_dir)

        repo_objs = get_repo_objs_from_provider(provider, args.repos)

        if repo_objs:
            for repo in repo_objs:
                repo_dir_to_create = os.path.join(args.staging_dir, repo.name)
                bundle_dir_to_create = os.path.join(abs_date_dir, repo.name)

                mkdir_p(repo_dir_to_create)
                mkdir_p(bundle_dir_to_create)

                bundle_file_to_create = os.path.join(
                    bundle_dir_to_create, "{}.bundle".format(repo.name))

                subprocess.check_call(
                    ["git",
                     "clone",
                     "--no-hardlinks",
                     "--mirror",
                     repo.clone_url,
                     repo_dir_to_create])

                os.chdir(repo_dir_to_create)

                subprocess.check_call(
                    ["git",
                     "bundle",
                     "create",
                     bundle_file_to_create,
                     "--all"])

                create_tarball([bundle_dir_to_create], repo.name, abs_date_dir)

                # cleanup
                rm_rf(bundle_dir_to_create)
    else:
        logging.error("Please provide repos to backup.")
예제 #4
0
def backup(args):

    if args.repos:

        provider = get_provider_from_config(args.config)

        today = datetime.datetime.now().date()
        abs_date_dir = get_abs_date_dir(args.archive_dir, today)

        mkdir_p(args.staging_dir)
        mkdir_p(args.archive_dir)
        mkdir_p(abs_date_dir)

        repo_objs = get_repo_objs_from_provider(provider, args.repos)

        if repo_objs:
            for repo in repo_objs:
                repo_dir_to_create = os.path.join(args.staging_dir, repo.name)
                bundle_dir_to_create = os.path.join(abs_date_dir, repo.name)

                mkdir_p(repo_dir_to_create)
                mkdir_p(bundle_dir_to_create)

                bundle_file_to_create = os.path.join(
                    bundle_dir_to_create, "{}.bundle".format(repo.name))

                subprocess.check_call([
                    "git", "clone", "--no-hardlinks", "--mirror",
                    repo.clone_url, repo_dir_to_create
                ])

                os.chdir(repo_dir_to_create)

                subprocess.check_call([
                    "git", "bundle", "create", bundle_file_to_create, "--all"
                ])

                create_tarball([bundle_dir_to_create], repo.name, abs_date_dir)

                # cleanup
                rm_rf(bundle_dir_to_create)
    else:
        logging.error("Please provide repos to backup.")