rake: accept BACKUP parameter while running the restore rake task, closes #220

This commit is contained in:
Sameer Naik 2014-12-03 22:38:49 +05:30
parent d203dbc317
commit 283bba3d2d
3 changed files with 35 additions and 14 deletions

View File

@ -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

View File

@ -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.

View File

@ -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