Backup and download scripts to compress with 7z data for a debian server and download it to another machine.
Guzmán Castanedo Villalba 43e7d438cd Update README.md | 6 lat temu | |
---|---|---|
scripts | 6 lat temu | |
LICENSE | 7 lat temu | |
README.md | 6 lat temu | |
backup-server | 6 lat temu | |
download-backup-http | 7 lat temu | |
download-backup-sftp | 7 lat temu |
Backup and download scripts to compress with:
The backup script (backup-server) backup the following server configuration:
Also it's:
# curl "https://code.castanedo.es/guzman/backup-server/archive/2.1.tar.gz" | tar -xz
# cp ./backup-server/backup-server /usr/local/bin/backup-server
# cp ./backup-server/scripts/cron.d/backup-server /etc/cron.d/backup-server
# cp ./backup-server/scripts/logrotate.d/backup-server /etc/logrotate.d/backup-server
# rm -R ./backup-server
Edit /etc/cron.d/backup-server
to automatic backups as desired.
# backup-server [options]... -z|-j|-J|-7 [backupdir]
backupdir
: argument to set to directory to save the backup
-p
, --prefix name
: prefix for the name of the backup
--postfix name
: postfix for the name of the backup.
--postfix ""
--no-remove
: no remove old files
--remove-days number
: set number of days to considere a backup old
-u
, --user uid
: name of the user owner of the backup
-g
, --group gid
: name of the group owner of the backup
--permision-mask number
: octal mask to set accesss permision of the backup
-z
, --gzip
: compress using gzip (tar.gz or tar.gz.gpg)-j
, --bzip2
: compress using bzip2 (tar.bz2 or tar.bz2.gpg)-J
, --xz
: compress using xz (tar.xz or tar.xz.gpg)-7
, --7zip
: compress using 7z (7z)-k
, --key-id ID
: set gpg2 public key-id used for encryption
--no-encryption
: disable the encryption of the backup
--7z-password password
: set password (ONLY for 7z)
--web-dir dir
: set web pages directory to backup
--no-web
: disable backup of web pages
--no-sql
: disable MySQL/MariaDB backup
--sql-user username
: set MySQL/MariaDB username
--sql-password password
: set MySQL/MariaDB password
--nginx-dir dir
: set nginx configuration directory to backup
--no-nginx
: disable Nginx backup
--letsencrypt-dir dir
: set Let's Encrypt configuration directory to backup
--no-letsencrypt
: disable Let's Encrypt backup
--mail-dir dir
: set Mailboxes directory to backup
--no-mail
: disable mailboxes backup
--home-dir dir
: set home directories to backup
--no-home
: disable home directory backup
--gogs-dir dir
: set GOGS Git Repository to backup
--no-gogs
: disable gogs backup
--postfix-dir dir
: set Postfix configuration directory to backup
--no-postfix
: disable Postfix backup
--dovecot-dir dir
: set Dovecot configuration directory to backup
--no-dovecot
: disable Dovecot backup
--opendkim-conf file
: set OpenDKIM configuration file to backup
--opendkim-default file
: set OpenDKIM socket configuration file to backup
--opendkim-keys dir
: set OpenDKIM keys dir to backup
--no-opendkim
: disable OpenDKIM backup
--spf-dir dir
: set SPF configuration directory to backup
--no-spf
: disable SPF backup
--opendmarc-conf file
: set OpenDMARC configuration file to backup
--opendmarc-default file
: set OpenDMARC socket configuration file to backup
--no-opendmarc
: disable OpenDMARC backup
--amavis-dir dir
: set Amavis configuration directory to backup
--no-amavis
: disable Amavis backup
--spamassassin-dir dir
: set SPAM Assassin configuration directory to backup
--no-spamassassin
: disable SPAM Assassin backup
--no-sha512
: not calculate SHA512 hash (to check integrity)-h
, --help
: shows this message and exitbackup-server --xz -k ABCDEFG -p backup-example.com --no-sql /var/backup
/var/backup
compressed with XZ and encrypted with GPG2 Public Key (backup-example.com-2018-03-19-a1b2c3.tar.xz.gpg
)backup-server -7 --7z-password 7zpass --sql-user root --sql-password toor /var/www/backup
/var/www/backup
compressed with 7Zip and encrypted (backup-castanedo.es-2018-03-19-abcedf.7z
)backup-server -z --no-encryption --no-sql /var/backup
/var/backup
compressed with GZip and not encrypted (backup-castanedo.es-2018-03-19-qwerty.tar.gz
)It's possible to make backups automatic creating a cron.d task (/etc/cron.d/backup-server
).
There are an example in scripts
folder.
The download script (download-backup-http) download all the compressed files in a remote machine, via http/https (with Auth Basic Aunthentication).
The download script (download-backup-sftp) download all the compressed files in a remote machine, via sftp (SSH File Transfer Protocol).
To autodownload the backups from another machine there are multiple solutions.