Mr_Horizon Ich habe einen nächtlichen Cronjob für das Mailcow Backup Script eingerichtet, welches ein lokales Backup in /opt/backup erstellt. Diesen Order synchronisiere ich dann wiederum via Rclone mit einem zweiten Cronjob auf ein Backblaze B2 Bucket. Hier meine Notizen, wie ich es eingerichtet habe:
1. Local backups
1.1 Backup
Create a backup directory:
mkdir /opt/backup
Create a manual backup:
MAILCOW_BACKUP_LOCATION=/opt/backup /opt/mailcow-dockerized/helper-scripts/backup_and_restore.sh backup all
Create a cronjob:
crontab -e
5 3 * * * cd /opt/mailcow-dockerized/; MAILCOW_BACKUP_LOCATION=/opt/backup /opt/mailcow-dockerized/helper-scripts/backup_and_restore.sh all --delete-days 3
https://mailcow.github.io/mailcow-dockerized-docs/backup_restore/b_n_r-backup/
1.2 Restore
To run a restore, start mailcow, use the script with “restore” as first parameter.
# Syntax:
# ./helper-scripts/backup_and_restore.sh restore
The script will ask you for a backup location containing the mailcow_DATE folders.
https://mailcow.github.io/mailcow-dockerized-docs/backup_restore/b_n_r-restore/
2. Cloud backups (Backblaze B2)
2.1 Install Rclone
curl https://rclone.org/install.sh | bash
https://rclone.org/install/
2.2 Configure Rclone
rclone config
No remotes found, make a new one?
n) New remote
s) Set configuration password
q) Quit config
n/s/q> n
name> backblaze
Option Storage.
Type of storage to configure.
Choose a number from below, or type in your own value.
Storage> b2
Option account.
Account ID or Application Key ID.
Enter a value.
account> ***Application-KeyID***
Option key.
Application Key.
Enter a value.
key> ****Application-Key****
Option hard_delete.
Permanently delete files on remote removal, otherwise hide files.
Enter a boolean value (true or false). Press Enter for the default (false).
hard_delete> ENTER
Edit advanced config?
y) Yes
n) No (default)
y/n> ENTER
--------------------
[backblaze]
type = b2
account = *********KeyID***********
key = ***********KEY************
--------------------
y) Yes this is OK (default)
e) Edit this remote
d) Delete this remote
y/e/d> ENTER
Name Type
==== ====
backblaze b2
e) Edit existing remote
n) New remote
d) Delete remote
r) Rename remote
c) Copy remote
s) Set configuration password
q) Quit config
e/n/d/r/c/s/q> n
name> backblaze-encrypted
Option Storage.
Type of storage to configure.
Choose a number from below, or type in your own value
Storage> crypt
Option remote.
Remote to encrypt/decrypt.
Normally should contain a ':' and a path, e.g. "myremote:path/to/dir",
"myremote:bucket" or maybe "myremote:" (not recommended).
Enter a value.
remote> backblaze:bucket-name
Option filename_encryption.
How to encrypt the filenames.
Choose a number from below, or type in your own string value.
Press Enter for the default (standard).
/ Encrypt the filenames.
1 | See the docs for the details.
\ (standard)
2 / Very simple filename obfuscation.
\ (obfuscate)
/ Don't encrypt the file names.
3 | Adds a ".bin" extension only.
\ (off)
filename_encryption> ENTER
Option directory_name_encryption.
Option to either encrypt directory names or leave them intact.
NB If filename_encryption is "off" then this option will do nothing.
Choose a number from below, or type in your own boolean value (true or false).
Press Enter for the default (true).
1 / Encrypt directory names.
\ (true)
2 / Don't encrypt directory names, leave them intact.
\ (false)
directory_name_encryption> ENTER
directory_name_encryption>
Option password.
Password or pass phrase for encryption.
Choose an alternative below.
y) Yes, type in my own password
g) Generate random password
y/g> y for existing remotes / backups
g for a new remote
Password or pass phrase for salt.
Optional but recommended.
Should be different to the previous password.
Choose an alternative below. Press Enter for the default (n).
y) Yes, type in my own password
g) Generate random password
n) No, leave this optional password blank (default)
y/g/n> y for existing remotes / backups
g for a new remote
Edit advanced config?
y) Yes
n) No (default)
y/n> ENTER
--------------------
[backblaze_encrypted]
type = crypt
remote = backblaze:bucket-name
password = *** ENCRYPTED ***
password2 = *** ENCRYPTED ***
--------------------
y) Yes this is OK (default)
e) Edit this remote
d) Delete this remote
y/e/d> ENTER
Name Type
==== ====
backblaze b2
backblaze-encrypted crypt
e) Edit existing remote
n) New remote
d) Delete remote
r) Rename remote
c) Copy remote
s) Set configuration password
q) Quit config
e/n/d/r/c/s/q> q
2.3 Manual backup and restore
Backup:
rclone sync -v /opt/backup/ backblaze-encrypted:bucket-name
Restore:
rclone sync -v backblaze-encrypted:bucket-name /opt/backup/
2.4 Create a cronjob
crontab -e
5 4 * * * rclone sync /opt/backup/ backblaze-encrypted:bucket-name