Commit 0b8d834b authored by Alain Takoudjou's avatar Alain Takoudjou Committed by Kirill Smelkov

gitlab-backup: don't keep backup_gitlab.pulled files

add option to remove or keep pulled backup data

[ kirr: The .pulled files with gitlab backup data (SQL and the like)
  were originally not removed "just in case" in the early days of
  git/gitlab-backup. They are clearly not needed to be kept since their
  content is entered into git backup database by gitlab-backup, and
  leaving those .pulled files just wastes disk space.

  So default to not keep them around and for now add an option to
  forcibly preserve the raw gitlab backup if we'll need it just in case or
  for the debugging.

  However if it turns out we won't really need -keep in practice, it
  might go away in some time. ]

/reviewed-on kirr/git-backup!3
parent c4d4e857
...@@ -104,6 +104,7 @@ need_gitlab_config() { ...@@ -104,6 +104,7 @@ need_gitlab_config() {
# pull gitlab data into git-backup repository # pull gitlab data into git-backup repository
backup_pull() { backup_pull() {
keep_pulled_backup=$1
need_gitlab_config need_gitlab_config
# 1. dump all gitlab data except repositories & db # 1. dump all gitlab data except repositories & db
...@@ -210,8 +211,13 @@ backup_pull() { ...@@ -210,8 +211,13 @@ backup_pull() {
echo " * git-backup pull everything" echo " * git-backup pull everything"
$GIT_BACKUP pull "$tmpd/gitlab_backup:gitlab/misc" $GITLAB_REPOS_PATH:gitlab/repo $GIT_BACKUP pull "$tmpd/gitlab_backup:gitlab/misc" $GITLAB_REPOS_PATH:gitlab/repo
# mark backup_tar as pulled and cleanup if [ "$keep_pulled_backup" == "n" ]; then
mv "$backup_tar" "$backup_tar.pulled" # remove pulled as they are not needed
rm -f "$backup_tar"
else
# mark backup_tar as pulled and cleanup
mv "$backup_tar" "$backup_tar.pulled"
fi
rm -rf "$tmpd" rm -rf "$tmpd"
echo OK echo OK
...@@ -387,7 +393,7 @@ umask 0077 # XXX maybe not good - e.g. git-data/repositories should (?) be rw ...@@ -387,7 +393,7 @@ umask 0077 # XXX maybe not good - e.g. git-data/repositories should (?) be rw
usage() { usage() {
echo "Usage: gitlab-backup [pull | restore (-vupok, -go) <commit-ish>]" echo "Usage: gitlab-backup [pull (-keep) | restore (-vupok, -go) <commit-ish>]"
} }
...@@ -397,7 +403,23 @@ shift ...@@ -397,7 +403,23 @@ shift
case "$action" in case "$action" in
pull) pull)
backup_pull keep=n # keep pulled gitlab backup data
while test $# != 0; do
case "$1" in
-keep)
keep=y
;;
-*)
die `usage`
;;
*)
break
;;
esac
shift
done
backup_pull $keep
;; ;;
restore) restore)
vupok=n # gitlab version >= backup's gitlab version is ok vupok=n # gitlab version >= backup's gitlab version is ok
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment