mirror of
https://github.com/mail-in-a-box/mailinabox.git
synced 2025-04-22 03:06:55 +00:00
Final corrections and tweaks
This commit is contained in:
parent
108cc55ca1
commit
2c6941c34c
@ -2,11 +2,10 @@
|
|||||||
|
|
||||||
# This script performs a backup of all user data:
|
# This script performs a backup of all user data:
|
||||||
# 1) System services are stopped while a copy of user data is made.
|
# 1) System services are stopped while a copy of user data is made.
|
||||||
# 2) An incremental backup is made using duplicity into the
|
# 2) An incremental encrypted backup is made using duplicity into the
|
||||||
# directory STORAGE_ROOT/backup/duplicity.
|
# directory STORAGE_ROOT/backup/encrypted. The password used for
|
||||||
|
# encryption is stored in backup/secret_key.txt.
|
||||||
# 3) The stopped services are restarted.
|
# 3) The stopped services are restarted.
|
||||||
# 4) The backup files are encrypted with a long password (stored in
|
|
||||||
# backup/secret_key.txt) to STORAGE_ROOT/backup/encrypted.
|
|
||||||
# 5) STORAGE_ROOT/backup/after-backup is executd if it exists.
|
# 5) STORAGE_ROOT/backup/after-backup is executd if it exists.
|
||||||
|
|
||||||
import os, os.path, shutil, glob, re, datetime
|
import os, os.path, shutil, glob, re, datetime
|
||||||
@ -14,13 +13,13 @@ import dateutil.parser, dateutil.relativedelta, dateutil.tz
|
|||||||
|
|
||||||
from utils import exclusive_process, load_environment, shell
|
from utils import exclusive_process, load_environment, shell
|
||||||
|
|
||||||
# destroy backups when the most recent increment in the chain
|
# Destroy backups when the most recent increment in the chain
|
||||||
# that depends on it is this many days old.
|
# that depends on it is this many days old.
|
||||||
keep_backups_for_days = 3
|
keep_backups_for_days = 3
|
||||||
|
|
||||||
def backup_status(env):
|
def backup_status(env):
|
||||||
# What is the current status of backups?
|
# What is the current status of backups?
|
||||||
# Loop through all of the files in STORAGE_ROOT/backup/duplicity to
|
# Loop through all of the files in STORAGE_ROOT/backup/encrypted to
|
||||||
# get a list of all of the backups taken and sum up file sizes to
|
# get a list of all of the backups taken and sum up file sizes to
|
||||||
# see how large the storage is.
|
# see how large the storage is.
|
||||||
|
|
||||||
@ -202,10 +201,8 @@ def perform_backup(full_backup):
|
|||||||
shell('check_call', [
|
shell('check_call', [
|
||||||
"/usr/bin/duplicity",
|
"/usr/bin/duplicity",
|
||||||
"full" if full_backup else "incr",
|
"full" if full_backup else "incr",
|
||||||
"--archive-dir", "/tmp/duplicity-archive-dir",
|
|
||||||
"--exclude", backup_dir,
|
"--exclude", backup_dir,
|
||||||
"--volsize", "100",
|
"--volsize", "250",
|
||||||
"--verbosity", "warning",
|
|
||||||
env["STORAGE_ROOT"],
|
env["STORAGE_ROOT"],
|
||||||
"file://" + backup_encrypted_dir
|
"file://" + backup_encrypted_dir
|
||||||
],
|
],
|
||||||
@ -222,20 +219,20 @@ def perform_backup(full_backup):
|
|||||||
shutil.rmtree(migrated_unencrypted_backup_dir)
|
shutil.rmtree(migrated_unencrypted_backup_dir)
|
||||||
|
|
||||||
# Remove old backups. This deletes all backup data no longer needed
|
# Remove old backups. This deletes all backup data no longer needed
|
||||||
# from more than 3 days ago. Must do this before destroying the
|
# from more than 3 days ago.
|
||||||
# cache directory or else this command will re-create it.
|
|
||||||
shell('check_call', [
|
shell('check_call', [
|
||||||
"/usr/bin/duplicity",
|
"/usr/bin/duplicity",
|
||||||
"remove-older-than",
|
"remove-older-than",
|
||||||
"%dD" % keep_backups_for_days,
|
"%dD" % keep_backups_for_days,
|
||||||
"--archive-dir", "/tmp/duplicity-archive-dir",
|
|
||||||
"--force",
|
"--force",
|
||||||
"--verbosity", "warning",
|
|
||||||
"file://" + backup_encrypted_dir
|
"file://" + backup_encrypted_dir
|
||||||
])
|
])
|
||||||
|
shell('check_call', [
|
||||||
# Remove duplicity's cache directory because it's redundant with our backup directory.
|
"/usr/bin/duplicity",
|
||||||
shutil.rmtree("/tmp/duplicity-archive-dir")
|
"cleanup",
|
||||||
|
"--force",
|
||||||
|
"file://" + backup_encrypted_dir
|
||||||
|
])
|
||||||
|
|
||||||
# Execute a post-backup script that does the copying to a remote server.
|
# Execute a post-backup script that does the copying to a remote server.
|
||||||
# Run as the STORAGE_USER user, not as root. Pass our settings in
|
# Run as the STORAGE_USER user, not as root. Pass our settings in
|
||||||
|
Loading…
Reference in New Issue
Block a user