Introduce 'help'
This adds a "help" text, so the user knows their options. Calling just the script will now tell the user to either user 'backup', 'restore', or 'help'.
This commit is contained in:
parent
0578729b92
commit
567ff84a25
|
@ -2,12 +2,50 @@
|
||||||
|
|
||||||
DEBIAN_DOCKER_IMAGE="mailcow/backup:1.0"
|
DEBIAN_DOCKER_IMAGE="mailcow/backup:1.0"
|
||||||
|
|
||||||
|
if [[ ${1} == "help" ]]; then
|
||||||
|
cat << END_OF_HELP
|
||||||
|
Script usage:
|
||||||
|
|
||||||
|
- Specify 'backup' or 'restore' mode:
|
||||||
|
backup_and_restore.sh backup
|
||||||
|
backup_and_restore.sh restore
|
||||||
|
|
||||||
|
- If you 'backup', you also have to specify what to backup.
|
||||||
|
Use 'backup' to see the backup options you can use.
|
||||||
|
|
||||||
|
backup_and_restore.sh backup
|
||||||
|
|
||||||
|
The script also comes with support for environment variables.
|
||||||
|
|
||||||
|
Available environment variables:
|
||||||
|
THREADS: Allows you to specify how many threads to backup with.
|
||||||
|
example: THREADS=4 backup_and_restore.sh backup all
|
||||||
|
|
||||||
|
NODATE: Allows you to omit the date stamped folder.
|
||||||
|
example: NODATE=1 backup_and_restore.sh backup all
|
||||||
|
|
||||||
|
You can combine the variables as well.
|
||||||
|
example: THREADS=4 NODATE=1 backup_and_restore.sh backup all
|
||||||
|
|
||||||
|
To do a full backup with the script, in an example "/backup/" folder:
|
||||||
|
echo "/backup/" | backup_and_restore.sh backup all
|
||||||
|
|
||||||
|
To do a full backup with 4 threads:
|
||||||
|
echo "/backup/" | THREADS=4 NODATE=1 backup_and_restore.sh backup all
|
||||||
|
|
||||||
|
To do a full backup with all available threads:
|
||||||
|
echo "/backup/" | THREADS=\`getconf _NPROCESSORS_ONLN\` NODATE=1 backup_and_restore.sh backup all
|
||||||
|
|
||||||
|
END_OF_HELP
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
if [[ ! -z ${MAILCOW_BACKUP_LOCATION} ]]; then
|
if [[ ! -z ${MAILCOW_BACKUP_LOCATION} ]]; then
|
||||||
BACKUP_LOCATION="${MAILCOW_BACKUP_LOCATION}"
|
BACKUP_LOCATION="${MAILCOW_BACKUP_LOCATION}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ ! ${1} =~ (backup|restore) ]]; then
|
if [[ ! ${1} =~ (backup|restore|help) ]]; then
|
||||||
echo "First parameter needs to be 'backup' or 'restore'"
|
echo "First parameter needs to be 'backup' or 'restore' or 'help'"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue