From d6f35d6f78da35b02fd132a1bf883aa3dcc043b2 Mon Sep 17 00:00:00 2001 From: Matthew Saunders Brown Date: Mon, 9 Oct 2023 16:35:14 -0700 Subject: [PATCH] new archive script --- bin/vmail-domains-arc.sh | 45 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100755 bin/vmail-domains-arc.sh diff --git a/bin/vmail-domains-arc.sh b/bin/vmail-domains-arc.sh new file mode 100755 index 0000000..d8aa9ac --- /dev/null +++ b/bin/vmail-domains-arc.sh @@ -0,0 +1,45 @@ +#!/bin/bash +# +# vmail-stack +# https://git.stack-source.com/msb/vmail-stack +# Copyright (c) 2023 Matthew Saunders Brown +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +# load include file +source $(dirname $0)/vmail.sh + +help() +{ + thisfilename=$(basename -- "$0") + echo "Create archive of vmail domain on this server. Includes emails and all email settings." + echo "" + echo "usage: $thisfilename -d [OPTIONS]" + echo "" + echo " -h Print this help." + echo " -d Domain name of vmail domain to create archive for." + exit +} + +vmail:getoptions "$@" + +# check for domain +if [[ -z $domain ]]; then + echo "domain is required" + exit +fi + +if [[ ! -d /var/vmail/$domain ]]; then + echo "vmail for $domain does not exist" + exit 1 +fi + +# create export of vmail settings +/usr/local/bin/vmail-domains-exp.sh -d $domain + +# make sure archive dir exists +if [[ ! -d /opt/archives ]]; then + mkdir /opt/archives +fi + +# create tarball +tar --directory=/var/vmail/ -czf /opt/archives/mail.$domain.tar.gz $domain