backup-rcopy/hosts/backup_script.sh.sample

273 lines
6.8 KiB
Bash

#!/usr/bin/env bash
# --------------------------------------------------- #
# -------------------- Variable --------------------- #
#
## --------------------------- ##
## - - ##
## - USER SETTINGS - ##
## - - ##
## --------------------------- ##
## - load default configuration
## -
. $rcopy_conf_file
. $rcopy_functions_file
## - set hostname, which is wanted to backup
## -
srcHost=<hostname (fqdn) or localhost>
## - sync via ssh tunnel
## -
## - if syncing via ssh sh_tunnel, create/modify file
## - ~/.ssh/config with the following contents
## -
## - host localhost
## - user back
## - Port 9999
## - ForwardAgent yes
## - StrictHostKeyChecking no
## - LogLevel FATAL
## -
## - NOTE !!
## - you cannot have different entries for localhost.
## -
## - A ssh tunnel localhost -> $target_host
## - will be created.
## -
ssh_tunnel=false
ssh_tunnel_local_port=9999
ssh_tunnel_target_port=22
ssh_tunnel_key_file=
## - if syncing via ssh hop-host, create/modify file
## - ~/.ssh/config with the following contents
## -
## - host localhost
## - user back
## - Port 9999
## - ForwardAgent yes
## - StrictHostKeyChecking no
## - LogLevel FATAL
## -
## - NOTE !!
## - you cannot have different entries for localhost.
## -
## - A ssh tunnel localhost -> $hop_host -> $target_host
## - will be created.
## -
ssh_hopping=false
ssh_hop_host=shell.so36.net
hop_host_port=1036
target_port=1036
local_port=9999
ssh_keyfile=$HOME/.ssh/id_dsa
## - remote user
## -
ssh_user=back
## - Commands executed on srcHost befor saving
## -
## - pre_backup_commands=("<USER>#<COMMAND>" ["<USER>#<COMMAND>"] ..)
## -
## - Example:
## - pre_backup_commands=(
## - "www-data#/usr/local/php/bin/php /var/www/cloud-02.oopen.de/htdocs/occ maintenance:mode --on"
## - ...
## - )
pre_backup_commands=()
## - Commands executed on srcHost after saving
## -
## - post_backup_commands=("<USER>#<COMMAND>" ["<USER>#<COMMAND>"] ..)
## -
## - Example:
## - post_backup_commands=(
## - "www-data#/usr/local/php/bin/php /var/www/cloud-02.oopen.de/htdocs/occ maintenance:mode --off"
## - ...
## - )
post_backup_commands=()
## - what to store ?
## -
## - these directories will be archived
## - into one file
##
dir_backup="<blank seperatet list of directories>"
## - backup network filesystems like nfs or smbfs
## -
## - NOTICE!
## - - mounting network devices is only possible on localhost - YET
## - - if network directory should mount, you need an entry in
## - /etc/fstab
## -
mount_netdir=false
net_mounted_dir_backup="<blank seperatet list of network directories>"
## - also store mysql databases ?
## -
mysql_backup=false
## - Since Version 5.6, giving password on command line is considered as insecure.
## - To avoid giving the password on command line, you can use an
## - encrypted option file instead.
## -
## - 1.) Create (encrypted) option file:
## - $ mysql_config_editor set --login-path=local --socket=/tmp/mysql.sock --user=backup --password
## - $ Password:
## -
## - Its possible to hold more than one credentials in this (encrypted) option file:
## - $ mysql_config_editor set --login-path=local-5.6 --socket=/tmp/mysql-5.6.sock --user=backup --password
## -
## -
## - 2.) Set environment variable mysql_credential_args="--login-path=local"
## - Now, the backup script uses the encrypted option file instead of (unencrypt) password
## - on command line.
## -
## - You can backup databases from different mysql installations i.e. for a (main)
## - MySQL installation and a second one using variable 'mysql_credential_args_arr':
## -
## - mysql_credential_args_arr=("<Name1>:<MySQL credentials1>" ""<Name1>:<MySQL credentials2>" ...
## -
## - Example:
## - mysql_credential_args_arr=("5.7:--login-path=local" "5.6:--login-path=local-5.6")
## -
#mysql_credential_args_arr=""
mysql_credential_args="--login-path=local"
mysql_user=backup
mysql_password=backup
## - gzip mysql dump files?
## -
mysql_gzip=false
## - restart apache after mysqldump
## -
restart_apache=false
## - also store postresql databases ?
## -
pgsql_backup=false
pgsql_user=postgres
## - gzip postgres dump files?
## -
pgsql_gzip=false
## - store disk settings
## -
disksetting_backup=false
## - store svn repositories ?
## -
svn_backup=false
svn_source_base_path="<path-to-svn i.e. /data/svn>"
## - gzip SVN backup files?
## -
svn_gzip=false
## - backup nextcloud accounts
## -
nextcloud_backup=false
## - nextcloud_server_url
## -
nextcloud_server_url="https://${srcHost}"
## - nextcloud_accounts
## -
## - !! Notice !!
## - ============
## - - delemiter between fields is th backtick sign: '`'
## - - single AND double quote sign CANNOT BE USED as a sign inside a field
## - - the single quote sign is used as begin/end sign for this variable
## -
## - nextcloud_accounts='<name1>`<password1>[`server_url] [<name2`password2>[`server_url] [..'
## -
## - Notice:
## - if 'server_url' is ommited, the value of variable 'nextcloud_server_url', the
## - default on, will be used.
## -
## - Example:
## -
## - nextcloud_accounts='
## - user1`P4ssw0rd1
## - user2`P4ssw0rd2`non-default-cloud-server-url
## - '
## -
nextcloud_accounts=''
## - Give rsync arguments here. Maybe you wish
## - to exclude some files or diredtories
## -
## - Note:
## - (Global) rsync options are already defined. See file 'conf/rcopy.conf'
## -
## - Add rsync options:
## -
#rsync_progArgs="$rsync_progArgs <more rsync options>"
## - replace #rsync_progArgs
## -
## - Note:
## - If backup device is on remote host, then rsync needs arguments:
## -
## - "--omit-link-times --munge-links"
## -
## - This is Added automaticaly done in file rcopy.conf and looks liek:
## -
## - if $remote_disk ; then
## - rsync_progArgs="--omit-link-times --munge-links $rsync_progArgs"
## - fi
## -
## - Take care to add this here if needed and rsync_progArgs are replaced!!
## -
#rsync_progArgs="<your-rsync-optargs>""
#
#if $remote_disk ; then
# rsync_progArgs="--omit-link-times --munge-links $rsync_progArgs"
#fi
## -----------------------------------------------------
## -
## - the following parameters overwrites the values from
## - the golbal configuration file
## - how long to hold backup-files ?
## -
#days=15
# a bigger (integer-)value for_DEBUG "1"results in more
# infomation, written to the logFile
#
# possible values: 0 , 1 or 2
#
#_DEBUG=0
# if _TEST is set to "1", nothing will be done. instead
# rsync will just report the actions it would have
# taken to the $logFile
#
#_TEST=0
export rcopy_functions_file srcHost ssh_user MIRROR ARCHIVE days _DEBUG _TEST ssh_hopping
## - Do the stuff - include main part of host script
## -
. $hosts_base_dir/scripts/main_part.include