diff --git a/Changelog.md b/Changelog.md index 4ea8a82b..6be0506e 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,5 +1,8 @@ # Changelog +**latest** +- accept `BACKUP` parameter while running the restore rake task, closes #220 + **7.5.2** - gitlab: upgrade to CE v.7.5.2 diff --git a/README.md b/README.md index 1f25e32e..ca74a3ea 100644 --- a/README.md +++ b/README.md @@ -811,6 +811,13 @@ docker run --name=gitlab -it --rm [OPTIONS] \ The restore operation will list all available backups in reverse chronological order. Select the backup you want to restore and gitlab will do its job. +To avoid user interaction in the restore operation, you can specify the timestamp of the specific backup using the `BACKUP` argument to the rake task. + +```bash +docker run --name=gitlab -it --rm [OPTIONS] \ + sameersbn/gitlab:7.5.2 app:rake gitlab:backup:restore BACKUP=1417624827 +``` + ## Automated Backups The image can be configured to automatically take backups on a daily, weekly or monthly basis. Adding `-e 'GITLAB_BACKUPS=daily'` to the docker run command will enable daily backups. Adding `-e 'GITLAB_BACKUPS=weekly'` or `-e 'GITLAB_BACKUPS=monthly'` will enable weekly or monthly backups. diff --git a/assets/init b/assets/init index 678a9a9d..d43ea45d 100755 --- a/assets/init +++ b/assets/init @@ -763,24 +763,35 @@ appRake () { echo "Running gitlab rake task..." if [ "$1" == "gitlab:backup:restore" ]; then - # user needs to select the backup to restore - nBackups=$(ls ${GITLAB_BACKUP_DIR}/*_gitlab_backup.tar | wc -l) - if [ $nBackups -eq 0 ]; then - echo "No backup present. Cannot continue restore process.". - return 1 - fi - - for b in `ls ${GITLAB_BACKUP_DIR} | sort -r` + # check if the BACKUP argument is specified + for a in $@ do - echo " ├ $b" + if [[ $a == BACKUP=* ]]; then + timestamp=${a:7} + break + fi done - read -p "Select a backup to restore: " file - if [ ! -f "${GITLAB_BACKUP_DIR}/${file}" ]; then - echo "Specified backup does not exist. Aborting..." - return 1 + if [ -z ${timestamp} ]; then + # user needs to select the backup to restore + nBackups=$(ls ${GITLAB_BACKUP_DIR}/*_gitlab_backup.tar | wc -l) + if [ $nBackups -eq 0 ]; then + echo "No backup present. Cannot continue restore process.". + return 1 + fi + + for b in `ls ${GITLAB_BACKUP_DIR} | sort -r` + do + echo " ├ $b" + done + read -p "Select a backup to restore: " file + + if [ ! -f "${GITLAB_BACKUP_DIR}/${file}" ]; then + echo "Specified backup does not exist. Aborting..." + return 1 + fi + timestamp=$(echo $file | cut -d'_' -f1) fi - timestamp=$(echo $file | cut -d'_' -f1) sudo -u git -H bundle exec rake gitlab:backup:restore BACKUP=$timestamp RAILS_ENV=production else [ "$1" == "gitlab:import:repos" ] && appSanitize