tachtler:dovecot_backup_-_skript
Unterschiede
Hier werden die Unterschiede zwischen zwei Versionen angezeigt.
Beide Seiten der vorigen RevisionVorhergehende ÜberarbeitungNächste Überarbeitung | Vorhergehende Überarbeitung | ||
tachtler:dovecot_backup_-_skript [2021/10/02 08:47] – [Voraussetzungen] klaus | tachtler:dovecot_backup_-_skript [2023/07/05 19:07] (aktuell) – [Dovecot Backup - Skript] klaus | ||
---|---|---|---|
Zeile 12: | Zeile 12: | ||
^ Beschreibung | ^ Beschreibung | ||
- | | Linux-Magazin | [[http:// | + | | Linux-Magazin | [[http:// |
| Homepage | | Homepage | ||
| Dokumentation | [[http:// | | Dokumentation | [[http:// | ||
Zeile 25: | Zeile 25: | ||
===== Zstandard (zstd) ===== | ===== Zstandard (zstd) ===== | ||
- | Für den Einsatz | + | Für den Einsatz der Komprimierungsmethode [[https:// |
+ | |||
+ | **__CentOS 7__** | ||
+ | |||
+ | Zur Installation von [[https:// | ||
+ | |||
+ | Nachfolgend soll das Repository des Drittanbieters [[https:// | ||
+ | * [[tachtler: | ||
+ | |||
+ | Zur Installation der Komprimierungsmethode [[https:// | ||
+ | * **'' | ||
+ | |||
+ | Mit nachfolgendem Befehl, werden die benötigten Pakete installiert: | ||
+ | < | ||
+ | # yum install zstd | ||
+ | Loaded plugins: changelog, priorities | ||
+ | 234 packages excluded due to repository priority protections | ||
+ | Resolving Dependencies | ||
+ | --> Running transaction check | ||
+ | ---> Package zstd.x86_64 0: | ||
+ | --> Finished Dependency Resolution | ||
+ | |||
+ | Changes in packages about to be updated: | ||
+ | |||
+ | |||
+ | Dependencies Resolved | ||
+ | |||
+ | ================================================================================ | ||
+ | | ||
+ | ================================================================================ | ||
+ | Installing: | ||
+ | | ||
+ | |||
+ | Transaction Summary | ||
+ | ================================================================================ | ||
+ | Install | ||
+ | |||
+ | Total download size: 649 k | ||
+ | Installed size: 2.1 M | ||
+ | Is this ok [y/d/N]: y | ||
+ | Downloading packages: | ||
+ | zstd-1.5.0-1.el7.x86_64.rpm | ||
+ | Running transaction check | ||
+ | Running transaction test | ||
+ | Transaction test succeeded | ||
+ | Running transaction | ||
+ | Installing : zstd-1.5.0-1.el7.x86_64 | ||
+ | Verifying | ||
+ | |||
+ | Installed: | ||
+ | zstd.x86_64 0: | ||
+ | |||
+ | Complete! | ||
+ | </ | ||
+ | |||
+ | Mit nachfolgendem Befehl kann überprüft werden, welcher Inhalt mit dem Paket installiert wurde. | ||
+ | |||
+ | Paket **zstd**: | ||
+ | < | ||
+ | # rpm -qil zstd | ||
+ | Name : zstd | ||
+ | Version | ||
+ | Release | ||
+ | Architecture: | ||
+ | Install Date: Sat 02 Oct 2021 07:40:55 AM CEST | ||
+ | Group : Unspecified | ||
+ | Size : 2178120 | ||
+ | License | ||
+ | Signature | ||
+ | Source RPM : zstd-1.5.0-1.el7.src.rpm | ||
+ | Build Date : Sun 16 May 2021 10:13:19 PM CEST | ||
+ | Build Host : buildhw-x86-12.iad2.fedoraproject.org | ||
+ | Relocations : (not relocatable) | ||
+ | Packager | ||
+ | Vendor | ||
+ | URL : https:// | ||
+ | Bug URL : https:// | ||
+ | Summary | ||
+ | Description : | ||
+ | Zstd, short for Zstandard, is a fast lossless compression algorithm, | ||
+ | targeting real-time compression scenarios at zlib-level compression ratio. | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | </ | ||
Zeile 67: | Zeile 168: | ||
# CUSTOM - Path and file name of a file with e-mail addresses to backup, if | # CUSTOM - Path and file name of a file with e-mail addresses to backup, if | ||
- | # SET. If NOT, the script will determine all mailboxes by default. | + | # SET. If NOT, the script will determine all mailboxes by default. |
# FILE_USERLIST='/ | # FILE_USERLIST='/ | ||
# - OR - | # - OR - | ||
Zeile 128: | Zeile 229: | ||
<code bash> | <code bash> | ||
- | #!/bin/bash | + | #!/usr/bin/env bash |
############################################################################## | ############################################################################## | ||
Zeile 137: | Zeile 238: | ||
# will be send by e-mail. | # will be send by e-mail. | ||
# # | # # | ||
- | # Last update : 02.10.2021 # | + | # Last update : 03.07.2023 # |
- | # Version | + | # Version |
# # | # # | ||
# Author | # Author | ||
Zeile 147: | Zeile 248: | ||
# | This program is free software; you can redistribute it and/or modify | # | # | This program is free software; you can redistribute it and/or modify | # | ||
# | it under the terms of the GNU General Public License as published by | # | # | it under the terms of the GNU General Public License as published by | # | ||
- | # | the Free Software Foundation; either version | + | # | the Free Software Foundation; either version |
# | (at your option) any later version. | # | (at your option) any later version. | ||
# +----------------------------------------------------------------------+ | # +----------------------------------------------------------------------+ | ||
# # | # # | ||
- | # Copyright (c) 2021 by Klaus Tachtler. | + | # Copyright (c) 2023 by Klaus Tachtler. |
# # | # # | ||
############################################################################## | ############################################################################## | ||
Zeile 205: | Zeile 306: | ||
# Version | # Version | ||
# Description : GitHub Issue #9 # | # Description : GitHub Issue #9 # | ||
- | # Add ability to only backup specific mailboxes, by using the # | + | # Add ability to only backup specific mailboxes, by using the # |
# | # | ||
# | # | ||
Zeile 274: | Zeile 375: | ||
# The error handling was also been improved. | # The error handling was also been improved. | ||
# | # | ||
+ | # -------------------------------------------------------------------------- # | ||
+ | # Version | ||
+ | # Description : GitHub: Issue #24 # | ||
+ | # | ||
+ | # | ||
+ | # -------------------------------------------------------------------------- # | ||
+ | # Version | ||
+ | # Description : GitHub: Pull request #26 # | ||
+ | # | ||
+ | # | ||
# -------------------------------------------------------------------------- # | # -------------------------------------------------------------------------- # | ||
# Version | # Version | ||
Zeile 304: | Zeile 415: | ||
# CUSTOM - Path and file name of a file with e-mail addresses to backup, if | # CUSTOM - Path and file name of a file with e-mail addresses to backup, if | ||
- | # SET. If NOT, the script will determine all mailboxes by default. | + | # SET. If NOT, the script will determine all mailboxes by default. |
# FILE_USERLIST='/ | # FILE_USERLIST='/ | ||
# - OR - | # - OR - | ||
Zeile 325: | Zeile 436: | ||
# Variables. | # Variables. | ||
- | DSYNC_COMMAND=`command -v dsync` | ||
TAR_COMMAND=`command -v tar` | TAR_COMMAND=`command -v tar` | ||
GZIP_COMMAND=`command -v gzip` | GZIP_COMMAND=`command -v gzip` | ||
Zeile 353: | Zeile 463: | ||
VAR_COUNT_USER=0 | VAR_COUNT_USER=0 | ||
VAR_COUNT_FAIL=0 | VAR_COUNT_FAIL=0 | ||
+ | |||
+ | # FreeBSD specific commands | ||
+ | if [ " | ||
+ | DSYNC_COMMAND=`command -v doveadm` | ||
+ | STAT_COMMAND_PARAM_FORMAT=' | ||
+ | STAT_COMMAND_ARG_FORMAT_USER=' | ||
+ | STAT_COMMAND_ARG_FORMAT_GROUP=' | ||
+ | MKTEMP_COMMAND_PARAM_ARG=" | ||
+ | else | ||
+ | DSYNC_COMMAND=`command -v dsync` | ||
+ | STAT_COMMAND_PARAM_FORMAT=' | ||
+ | STAT_COMMAND_ARG_FORMAT_USER=' | ||
+ | STAT_COMMAND_ARG_FORMAT_GROUP=' | ||
+ | MKTEMP_COMMAND_PARAM_ARG=" | ||
+ | fi | ||
# Functions. | # Functions. | ||
function log() { | function log() { | ||
- | echo $1 | + | |
- | echo `$DATE_COMMAND ' | + | echo `$DATE_COMMAND ' |
} | } | ||
function retval() { | function retval() { | ||
if [ " | if [ " | ||
- | case " | + | |
- | *) | + | *) |
- | log " | + | log " |
- | ;; | + | ;; |
- | esac | + | esac |
fi | fi | ||
} | } | ||
Zeile 372: | Zeile 497: | ||
function movelog() { | function movelog() { | ||
$CAT_COMMAND $FILE_LAST_LOG >> $FILE_LOG | $CAT_COMMAND $FILE_LAST_LOG >> $FILE_LOG | ||
- | $RM_COMMAND -f $FILE_LAST_LOG | + | $RM_COMMAND -f $FILE_LAST_LOG |
$RM_COMMAND -f $FILE_LOCK | $RM_COMMAND -f $FILE_LOCK | ||
} | } | ||
function sendmail() { | function sendmail() { | ||
- | case " | + | |
- | ' | + | ' |
- | MAIL_SUBJECT=' | + | MAIL_SUBJECT=' |
- | ;; | + | ;; |
- | *) | + | *) |
- | MAIL_SUBJECT=' | + | MAIL_SUBJECT=' |
- | ;; | + | ;; |
- | esac | + | esac |
- | $CAT_COMMAND <<-MAIL > | + | $CAT_COMMAND << |
- | Subject: $MAIL_SUBJECT | + | Subject: $MAIL_SUBJECT |
- | Date: $VAR_EMAILDATE | + | Date: $VAR_EMAILDATE |
- | From: $VAR_SENDER | + | From: $VAR_SENDER |
- | To: $MAIL_RECIPIENT | + | To: $MAIL_RECIPIENT |
- | + | ||
- | $CAT_COMMAND $FILE_LAST_LOG >> $FILE_MAIL | + | $CAT_COMMAND $FILE_LAST_LOG >> $FILE_MAIL |
- | $PROG_SENDMAIL -f $VAR_SENDER -t $MAIL_RECIPIENT < $FILE_MAIL | + | $PROG_SENDMAIL -f $VAR_SENDER -t $MAIL_RECIPIENT < $FILE_MAIL |
- | $RM_COMMAND -f $FILE_MAIL | + | $RM_COMMAND -f $FILE_MAIL |
} | } | ||
Zeile 406: | Zeile 531: | ||
CODE_ERROR=" | CODE_ERROR=" | ||
- | sendmail ERROR | + | |
movelog | movelog | ||
exit $CODE_ERROR | exit $CODE_ERROR | ||
Zeile 416: | Zeile 541: | ||
LINE_COUNT=68 | LINE_COUNT=68 | ||
- | # Help variables. | + | |
- | WORD_COUNT=`echo $TEXT_INPUT | wc -c` | + | WORD_COUNT=`echo $TEXT_INPUT | wc -c` |
- | CHAR_AFTER=`expr $LINE_COUNT - $WORD_COUNT - 5` | + | CHAR_AFTER=`expr $LINE_COUNT - $WORD_COUNT - 5` |
- | LINE_SPACE=`expr $LINE_COUNT - 3` | + | LINE_SPACE=`expr $LINE_COUNT - 3` |
# Format placeholder. | # Format placeholder. | ||
Zeile 440: | Zeile 565: | ||
LINE_COUNT=68 | LINE_COUNT=68 | ||
- | # Help variables. | + | |
- | WORD_COUNT=`echo $TEXT_INPUT | wc -c` | + | WORD_COUNT=`echo $TEXT_INPUT | wc -c` |
- | CHAR_AFTER=`expr $LINE_COUNT - $WORD_COUNT - 9` | + | CHAR_AFTER=`expr $LINE_COUNT - $WORD_COUNT - 9` |
# Format placeholder. | # Format placeholder. | ||
Zeile 460: | Zeile 585: | ||
function checkcommand () { | function checkcommand () { | ||
# Parameters. | # Parameters. | ||
- | TEXT_VARIABLE="$1" | + | CHECK_COMMAND=" |
- | CHECK_COMMAND=" | + | |
- | if [ ! -s "$2" ]; then | + | if [ ! -s "$1" ]; then |
- | logline "Check if command | + | logline "Check if command ' |
error 10 | error 10 | ||
else | else | ||
- | logline "Check if command | + | logline "Check if command ' |
fi | fi | ||
} | } | ||
Zeile 477: | Zeile 601: | ||
log "" | log "" | ||
log " | log " | ||
+ | log "" | ||
+ | log " | ||
log "" | log "" | ||
log " | log " | ||
Zeile 492: | Zeile 618: | ||
# Check if compress extension is allowed. | # Check if compress extension is allowed. | ||
if [[ $COMPRESSION != ' | if [[ $COMPRESSION != ' | ||
- | logline "Check compression extension" | + | |
- | log "" | + | log "" |
- | log " | + | log " |
- | log "" | + | log "" |
- | error 19 | + | error 19 |
fi | fi | ||
# Check if command (file) NOT exist OR IS empty. | # Check if command (file) NOT exist OR IS empty. | ||
- | checkcommand | + | checkcommand $DSYNC_COMMAND |
- | checkcommand | + | checkcommand $TAR_COMMAND |
- | checkcommand | + | checkcommand $TOUCH_COMMAND |
- | checkcommand | + | checkcommand $RM_COMMAND |
- | checkcommand | + | checkcommand $CAT_COMMAND |
- | checkcommand | + | checkcommand $DATE_COMMAND |
- | checkcommand | + | checkcommand $MKDIR_COMMAND |
- | checkcommand | + | checkcommand $CHOWN_COMMAND |
- | checkcommand | + | checkcommand $CHMOD_COMMAND |
- | checkcommand | + | checkcommand $GREP_COMMAND |
- | checkcommand | + | checkcommand $MKTEMP_COMMAND |
- | checkcommand | + | checkcommand $MV_COMMAND |
- | checkcommand | + | checkcommand $STAT_COMMAND |
- | checkcommand | + | checkcommand $PROG_SENDMAIL |
if [ $COMPRESSION = ' | if [ $COMPRESSION = ' | ||
- | checkcommand | + | |
fi | fi | ||
if [ $COMPRESSION = ' | if [ $COMPRESSION = ' | ||
- | checkcommand | + | |
fi | fi | ||
# Check if LOCK file NOT exist. | # Check if LOCK file NOT exist. | ||
if [ ! -e " | if [ ! -e " | ||
- | logline "Check if the script is NOT already runnig " true | + | |
- | $TOUCH_COMMAND $FILE_LOCK | + | |
else | else | ||
- | logline "Check if the script is NOT already runnig " false | + | |
- | log "" | + | log "" |
- | log " | + | log " |
- | log "" | + | log "" |
error 20 | error 20 | ||
fi | fi | ||
Zeile 538: | Zeile 664: | ||
# Check if TMP_FOLDER directory path NOT exists, else create it. | # Check if TMP_FOLDER directory path NOT exists, else create it. | ||
if [ ! -d " | if [ ! -d " | ||
- | logline "Check if TMP_FOLDER exists " false | + | |
$MKDIR_COMMAND -p $TMP_FOLDER | $MKDIR_COMMAND -p $TMP_FOLDER | ||
- | if [ " | + | if [ " |
- | logline " | + | logline " |
- | error 21 | + | error 21 |
+ | else | ||
+ | logline " | ||
+ | fi | ||
else | else | ||
- | logline " | + | |
- | fi | + | |
- | else | + | |
- | logline "Check if TMP_FOLDER exists " true | + | |
fi | fi | ||
# Check if TMP_FOLDER is owned by $MAILDIR_USER. | # Check if TMP_FOLDER is owned by $MAILDIR_USER. | ||
- | if [ " | + | if [ " |
- | logline "Check if TMP_FOLDER owner is $MAILDIR_USER " false | + | logline "Check if TMP_FOLDER owner is $MAILDIR_USER " false |
$CHOWN_COMMAND -R $MAILDIR_USER: | $CHOWN_COMMAND -R $MAILDIR_USER: | ||
- | if [ " | + | if [ " |
- | logline "Set ownership of TMP_FOLDER to $MAILDIR_USER: | + | logline "Set ownership of TMP_FOLDER to $MAILDIR_USER: |
- | error 22 | + | error 22 |
+ | else | ||
+ | logline "Set ownership of TMP_FOLDER to $MAILDIR_USER: | ||
+ | fi | ||
else | else | ||
- | logline "Set ownership of TMP_FOLDER to $MAILDIR_USER: | + | |
- | fi | + | |
- | else | + | |
- | logline "Check if TMP_FOLDER owner is $MAILDIR_USER " true | + | |
fi | fi | ||
# Check if TMP_FOLDER group is $MAILDIR_GROUP. | # Check if TMP_FOLDER group is $MAILDIR_GROUP. | ||
- | if [ " | + | if [ " |
- | logline "Check if TMP_FOLDER group is $MAILDIR_GROUP " false | + | logline "Check if TMP_FOLDER group is $MAILDIR_GROUP " false |
$CHOWN_COMMAND -R $MAILDIR_USER: | $CHOWN_COMMAND -R $MAILDIR_USER: | ||
- | if [ " | + | if [ " |
- | logline "Set ownership of TMP_FOLDER to $MAILDIR_USER: | + | logline "Set ownership of TMP_FOLDER to $MAILDIR_USER: |
- | error 23 | + | error 23 |
+ | else | ||
+ | logline "Set ownership of TMP_FOLDER to $MAILDIR_USER: | ||
+ | fi | ||
else | else | ||
- | logline "Set ownership of TMP_FOLDER to $MAILDIR_USER: | + | |
- | fi | + | |
- | else | + | |
- | logline "Check if TMP_FOLDER group is $MAILDIR_GROUP " true | + | |
fi | fi | ||
# Check if DIR_BACKUP directory NOT exists, else create it. | # Check if DIR_BACKUP directory NOT exists, else create it. | ||
if [ ! -d " | if [ ! -d " | ||
- | logline "Check if DIR_BACKUP exists " false | + | |
$MKDIR_COMMAND -p $DIR_BACKUP | $MKDIR_COMMAND -p $DIR_BACKUP | ||
- | if [ " | + | if [ " |
- | logline " | + | logline " |
- | error 24 | + | error 24 |
- | else | + | else |
- | logline " | + | logline " |
- | fi | + | fi |
else | else | ||
- | logline "Check if DIR_BACKUP exists " true | + | |
fi | fi | ||
# Check if DIR_BACKUP is owned by $MAILDIR_USER. | # Check if DIR_BACKUP is owned by $MAILDIR_USER. | ||
- | if [ " | + | if [ " |
- | logline "Check if DIR_BACKUP owner is $MAILDIR_USER " false | + | logline "Check if DIR_BACKUP owner is $MAILDIR_USER " false |
$CHOWN_COMMAND -R $MAILDIR_USER: | $CHOWN_COMMAND -R $MAILDIR_USER: | ||
- | if [ " | + | if [ " |
- | logline "Set ownership of DIR_BACKUP to $MAILDIR_USER: | + | logline "Set ownership of DIR_BACKUP to $MAILDIR_USER: |
- | error 25 | + | error 25 |
+ | else | ||
+ | logline "Set ownership of DIR_BACKUP to $MAILDIR_USER: | ||
+ | fi | ||
else | else | ||
- | logline "Set ownership of DIR_BACKUP to $MAILDIR_USER: | + | |
- | fi | + | |
- | else | + | |
- | logline "Check if DIR_BACKUP owner is $MAILDIR_USER " true | + | |
fi | fi | ||
# Check if DIR_BACKUP group is $MAILDIR_GROUP. | # Check if DIR_BACKUP group is $MAILDIR_GROUP. | ||
- | if [ " | + | if [ " |
- | logline "Check if DIR_BACKUP group is $MAILDIR_GROUP " false | + | logline "Check if DIR_BACKUP group is $MAILDIR_GROUP " false |
$CHOWN_COMMAND -R $MAILDIR_USER: | $CHOWN_COMMAND -R $MAILDIR_USER: | ||
- | if [ " | + | if [ " |
- | logline "Set ownership of DIR_BACKUP to $MAILDIR_USER: | + | logline "Set ownership of DIR_BACKUP to $MAILDIR_USER: |
- | error 26 | + | error 26 |
+ | else | ||
+ | logline "Set ownership of DIR_BACKUP to $MAILDIR_USER: | ||
+ | fi | ||
else | else | ||
- | logline "Set ownership of DIR_BACKUP to $MAILDIR_USER: | + | |
- | fi | + | |
- | else | + | |
- | logline "Check if DIR_BACKUP group is $MAILDIR_GROUP " true | + | |
fi | fi | ||
Zeile 623: | Zeile 749: | ||
log "" | log "" | ||
if [ ! -n " | if [ ! -n " | ||
- | log "Check if the variable FILE_USERLIST is set ................[ | + | |
- | log " | + | log " |
- | for users in `doveadm user " | + | for users in `doveadm user " |
- | VAR_LISTED_USER+=($users); | + | VAR_LISTED_USER+=($users); |
- | done | + | done |
else | else | ||
- | logline "Check if the variable FILE_USERLIST is set " true | + | |
- | log " | + | log " |
- | log "" | + | log "" |
- | log "- File: [$FILE_USERLIST]" | + | log "- File: [$FILE_USERLIST]" |
- | # Check if file exists. | + | # Check if file exists. |
- | if [ -f " | + | if [ -f " |
- | logline "- Check if FILE_USERLIST exists " true | + | logline "- Check if FILE_USERLIST exists " true |
- | else | + | else |
- | logline "- Check if FILE_USERLIST exists " false | + | logline "- Check if FILE_USERLIST exists " false |
- | log "" | + | log "" |
- | error 30 | + | error 30 |
- | fi | + | fi |
- | # Check if file is readable. | + | # Check if file is readable. |
- | if [ -r " | + | if [ -r " |
- | logline "- Check if FILE_USERLIST is readable " true | + | logline "- Check if FILE_USERLIST is readable " true |
- | else | + | else |
- | logline "- Check if FILE_USERLIST is readable " false | + | logline "- Check if FILE_USERLIST is readable " false |
- | log "" | + | log "" |
- | error 31 | + | error 31 |
- | fi | + | fi |
+ | |||
+ | # Read file into variable. | ||
+ | while IFS= read -r line | ||
+ | do | ||
+ | # Check for valid e-mail address. | ||
+ | if [ $FILE_USERLIST_VALIDATE_EMAIL = ' | ||
+ | # Check if basic email address syntax is valid. | ||
+ | if echo " | ||
+ | VAR_LISTED_USER+=($line); | ||
+ | else | ||
+ | log "" | ||
+ | log " | ||
- | # Read file into variable. | + | ((VAR_COUNT_FAIL++)) |
- | while IFS= read -r line | + | VAR_FAILED_USER+=($line); |
- | do | + | fi |
- | # Check for valid e-mail address. | + | else |
- | if [ $FILE_USERLIST_VALIDATE_EMAIL = ' | + | |
- | # Check if basic email address syntax is valid. | + | |
- | if echo " | + | |
VAR_LISTED_USER+=($line); | VAR_LISTED_USER+=($line); | ||
- | else | ||
- | log "" | ||
- | log " | ||
- | |||
- | ((VAR_COUNT_FAIL++)) | ||
- | VAR_FAILED_USER+=($line); | ||
fi | fi | ||
- | else | ||
- | VAR_LISTED_USER+=($line); | ||
- | fi | ||
done <" | done <" | ||
Zeile 685: | Zeile 811: | ||
# Make temporary directory DIR_TEMP inside TMP_FOLDER. | # Make temporary directory DIR_TEMP inside TMP_FOLDER. | ||
- | DIR_TEMP=$($MKTEMP_COMMAND | + | DIR_TEMP=$($MKTEMP_COMMAND $MKTEMP_COMMAND_PARAM_ARG) |
if [ " | if [ " | ||
logline " | logline " | ||
Zeile 697: | Zeile 823: | ||
$CHOWN_COMMAND -R $MAILDIR_USER: | $CHOWN_COMMAND -R $MAILDIR_USER: | ||
if [ " | if [ " | ||
- | logline "Set ownership of DIR_TEMP to $MAILDIR_USER: | + | logline "Set ownership of DIR_TEMP to $MAILDIR_USER: |
error 41 | error 41 | ||
else | else | ||
- | logline "Set ownership of DIR_TEMP to $MAILDIR_USER: | + | logline "Set ownership of DIR_TEMP to $MAILDIR_USER: |
log "" | log "" | ||
fi | fi | ||
Zeile 715: | Zeile 841: | ||
log " | log " | ||
- | $DSYNC_COMMAND -o plugin/ | + | |
+ | if [ " | ||
+ | $DSYNC_COMMAND -o plugin/ | ||
+ | else | ||
+ | $DSYNC_COMMAND -o plugin/ | ||
+ | fi | ||
# Check the status of dsync and continue the script depending on the result. | # Check the status of dsync and continue the script depending on the result. | ||
Zeile 732: | Zeile 863: | ||
VAR_FAILED_USER+=($users); | VAR_FAILED_USER+=($users); | ||
else | else | ||
- | log " | + | log " |
cd $DIR_TEMP | cd $DIR_TEMP | ||
log " | log " | ||
- | $TAR_COMMAND -acvf $users-$FILE_BACKUP $USERPART --atime-preserve --preserve-permissions | + | if [ " |
+ | $TAR_COMMAND -cvzf $users-$FILE_BACKUP $USERPART | ||
+ | else | ||
+ | $TAR_COMMAND -cvzf $users-$FILE_BACKUP $USERPART --atime-preserve --preserve-permissions | ||
+ | fi | ||
log " | log " | ||
- | $RM_COMMAND " | + | $RM_COMMAND |
if [ " | if [ " | ||
- | logline " | + | logline " |
else | else | ||
- | logline " | + | logline " |
fi | fi | ||
Zeile 750: | Zeile 885: | ||
$MV_COMMAND " | $MV_COMMAND " | ||
if [ " | if [ " | ||
- | logline "Move archive file for user to: $DIR_BACKUP " false | + | logline "Move archive file for user to: $DIR_BACKUP " false |
else | else | ||
- | logline "Move archive file for user to: $DIR_BACKUP " true | + | logline "Move archive file for user to: $DIR_BACKUP " true |
fi | fi | ||
Zeile 760: | Zeile 895: | ||
(ls -t $users-$FILE_DELETE|head -n $BACKUPFILES_DELETE; | (ls -t $users-$FILE_DELETE|head -n $BACKUPFILES_DELETE; | ||
if [ " | if [ " | ||
- | logline " | + | logline " |
else | else | ||
- | logline " | + | logline " |
fi | fi | ||
fi | fi | ||
log "Ended backup process for user: $users ..." | log "Ended backup process for user: $users ..." | ||
- | log "" | + | |
done | done | ||
# Delete the temporary folder DIR_TEMP. | # Delete the temporary folder DIR_TEMP. | ||
- | $RM_COMMAND | + | $RM_COMMAND -rf $DIR_TEMP |
if [ " | if [ " | ||
logline " | logline " | ||
Zeile 783: | Zeile 918: | ||
$CHOWN_COMMAND -R $MAILDIR_USER: | $CHOWN_COMMAND -R $MAILDIR_USER: | ||
if [ " | if [ " | ||
- | logline "Set ownership of DIR_BACKUP to $MAILDIR_USER: | + | logline "Set ownership of DIR_BACKUP to $MAILDIR_USER: |
error 43 | error 43 | ||
else | else | ||
- | logline "Set ownership of DIR_BACKUP to $MAILDIR_USER: | + | logline "Set ownership of DIR_BACKUP to $MAILDIR_USER: |
fi | fi | ||
Zeile 792: | Zeile 927: | ||
$CHMOD_COMMAND 700 $DIR_BACKUP | $CHMOD_COMMAND 700 $DIR_BACKUP | ||
if [ " | if [ " | ||
- | logline "Set permission of DIR_BACKUP to drwx------ " false | + | logline "Set permission of DIR_BACKUP to drwx------ " false |
error 44 | error 44 | ||
else | else | ||
- | logline "Set permission of DIR_BACKUP to drwx------ " true | + | logline "Set permission of DIR_BACKUP to drwx------ " true |
fi | fi | ||
Zeile 801: | Zeile 936: | ||
$CHMOD_COMMAND -R 600 $DIR_BACKUP/ | $CHMOD_COMMAND -R 600 $DIR_BACKUP/ | ||
if [ " | if [ " | ||
- | logline "Set file permissions in DIR_BACKUP to -rw------- " false | + | logline "Set file permissions in DIR_BACKUP to -rw------- " false |
error 45 | error 45 | ||
else | else | ||
- | logline "Set file permissions in DIR_BACKUP to -rw------- " true | + | logline "Set file permissions in DIR_BACKUP to -rw------- " true |
log "" | log "" | ||
fi | fi | ||
Zeile 810: | Zeile 945: | ||
# Delete LOCK file. | # Delete LOCK file. | ||
if [ " | if [ " | ||
- | retval $? | + | |
- | log "" | + | log "" |
- | $RM_COMMAND -f $FILE_LOCK | + | $RM_COMMAND -f $FILE_LOCK |
error 99 | error 99 | ||
else | else | ||
headerblock "End backup $SCRIPT_NAME " | headerblock "End backup $SCRIPT_NAME " | ||
- | log "" | + | |
fi | fi | ||
Zeile 835: | Zeile 970: | ||
log "" | log "" | ||
END_TIMESTAMP=`$DATE_COMMAND ' | END_TIMESTAMP=`$DATE_COMMAND ' | ||
- | log " | + | if [ " |
+ | DELTA=$((END_TIMESTAMP-RUN_TIMESTAMP)) | ||
+ | log " | ||
+ | else | ||
+ | log " | ||
+ | fi | ||
log "" | log "" | ||
headerblock " | headerblock " | ||
Zeile 842: | Zeile 982: | ||
# If errors occurred on user backups, exit with return code 1 instead of 0. | # If errors occurred on user backups, exit with return code 1 instead of 0. | ||
if [ " | if [ " | ||
- | sendmail ERROR | + | |
# Move the log to the permanent log file. | # Move the log to the permanent log file. | ||
movelog | movelog | ||
Zeile 849: | Zeile 989: | ||
# Status e-mail. | # Status e-mail. | ||
if [ $MAIL_STATUS = ' | if [ $MAIL_STATUS = ' | ||
- | sendmail STATUS | + | sendmail STATUS |
fi | fi | ||
# Move the log to the permanent log file. | # Move the log to the permanent log file. | ||
Zeile 890: | Zeile 1030: | ||
# / | # / | ||
- | +-----------------------------------------------------------------+ | + | +-------------------------------------------------------------------+ |
| Start backup of the mailboxes [Sat, 02 Oct 2021 08:18:37 (+0200)] | | | Start backup of the mailboxes [Sat, 02 Oct 2021 08:18:37 (+0200)] | | ||
- | +-----------------------------------------------------------------+ | + | +-------------------------------------------------------------------+ |
SCRIPT_NAME.................: | SCRIPT_NAME.................: | ||
+ | |||
+ | OS_TYPE.....................: | ||
COMPRESSION.................: | COMPRESSION.................: | ||
Zeile 978: | Zeile 1120: | ||
SCRIPT_NAME.................: | SCRIPT_NAME.................: | ||
+ | |||
+ | OS_TYPE.....................: | ||
COMPRESSION.................: | COMPRESSION.................: |
tachtler/dovecot_backup_-_skript.1633157257.txt.gz · Zuletzt geändert: 2021/10/02 08:47 von klaus