Implement custom directory backup
This commit is contained in:
parent
fa3ca3cf63
commit
472e490ea1
@ -47,6 +47,8 @@ All configuration options can be found in the `backup.cfg` file. The script has
|
|||||||
| db_password | ------> | Password for DB access |
|
| db_password | ------> | Password for DB access |
|
||||||
| db_name | ------> | Name of database |
|
| db_name | ------> | Name of database |
|
||||||
| db_all | ------> | Dump all databases instead of specific one |
|
| db_all | ------> | Dump all databases instead of specific one |
|
||||||
|
| custom_backup | true/false | Enable backup of custom files |
|
||||||
|
| custom_dirs | ------> | Array of files/directories to backup
|
||||||
|
|
||||||
|
|
||||||
## Logs to backup array 📚
|
## Logs to backup array 📚
|
||||||
|
14
backup.cfg
14
backup.cfg
@ -2,12 +2,12 @@
|
|||||||
# --------------------------------------------------------
|
# --------------------------------------------------------
|
||||||
# Please double check Your settings
|
# Please double check Your settings
|
||||||
# --------------------------------------------------------
|
# --------------------------------------------------------
|
||||||
enabled=false #enable main function
|
enabled=false #enable the script
|
||||||
backup_path='/opt/backify/' # location of backups
|
backup_path='/opt/backify/' # where do you want backups saved
|
||||||
www_backup=false # backup wwwroot
|
www_backup=false # backup wwwroot
|
||||||
www_dir='xyz' # wwwroot location
|
www_dir='xyz' # location of wwwroot to backup
|
||||||
vhost_backup=false # backup vhost config
|
vhost_backup=false # backup vhost configurations
|
||||||
vhost_dir='/etc/httpd/sites-enabled' # vhost location
|
vhost_dir='/etc/httpd/sites-enabled' # location of active vhost files
|
||||||
log_backup=false # backup logs
|
log_backup=false # backup logs
|
||||||
log_to_backup=("apache" "nginx" "fail2ban" "pckg_mngr" "auth" "dmesg" "dpkg" "letsencrypt" "php" "syslog" "purge")
|
log_to_backup=("apache" "nginx" "fail2ban" "pckg_mngr" "auth" "dmesg" "dpkg" "letsencrypt" "php" "syslog" "purge")
|
||||||
# logs to backup, options: apache, nginx, fail2ban, pckg_mngr, auth, dmesg, dpkg, letsencrypt, php, syslog, purge (truncate all))
|
# logs to backup, options: apache, nginx, fail2ban, pckg_mngr, auth, dmesg, dpkg, letsencrypt, php, syslog, purge (truncate all))
|
||||||
@ -26,4 +26,6 @@ database_type=mysql #mysql or postgresql
|
|||||||
db_username=user #database user
|
db_username=user #database user
|
||||||
db_password=user #database password
|
db_password=user #database password
|
||||||
db_all=false #dumps all databases if true
|
db_all=false #dumps all databases if true
|
||||||
db_name=user #name of the database
|
db_name=user #name of the database
|
||||||
|
custom_backup=false #backup custom files or directories
|
||||||
|
custom_dirs=("/opt/example" "/var/log/script.log") #array of custom files and/or directories to backup
|
12
main.sh
12
main.sh
@ -331,6 +331,16 @@ function backup_db {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function custombackup {
|
||||||
|
if [ "$custom_backup" = "true" ]; then
|
||||||
|
mkdir -p "$tmpdir/custom"
|
||||||
|
for i in "${custom_dirs[@]}"
|
||||||
|
do
|
||||||
|
cp -r $i $tmpdir/custom/
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
function runbackup {
|
function runbackup {
|
||||||
# init, config check
|
# init, config check
|
||||||
init
|
init
|
||||||
@ -351,6 +361,8 @@ function runbackup {
|
|||||||
if [ "$db_backup" = true ]; then
|
if [ "$db_backup" = true ]; then
|
||||||
backup_db
|
backup_db
|
||||||
fi
|
fi
|
||||||
|
# step 7 : custom backup
|
||||||
|
custombackup
|
||||||
# archive data
|
# archive data
|
||||||
echo "Creating backup archive..." >&2
|
echo "Creating backup archive..." >&2
|
||||||
tar -czvf $backup_path/backify-$timestamp.tar.gz $tmpdir
|
tar -czvf $backup_path/backify-$timestamp.tar.gz $tmpdir
|
||||||
|
Loading…
Reference in New Issue
Block a user