Restic backup script simple (fresco fresco callo callo)

 ### backupscript.sh


export RESTIC_REPOSITORY=sftp:administrator@172.16.7.1:/e:/resticroot ##this is a windows sftp server
export RESTIC_PASSWORD=passwordstring
restic --verbose backup /srv
if [ $? -ne 0 ]
then
  sed -i '1s/^/Subject: restic error\n/' /root/restic_jobs/transcript.log
  cat /root/restic_jobs/transcript.log | ssmtp -vvv email@provider.com
fi

restic --verbose forget --keep-last 2 --prune
        if [ $? -ne 0 ]
then
sed -i '1s/^/Subject: restic error\n/' /root/restic_jobs/transcript.log
cat /root/restic_jobs/transcript.log | ssmtp -vvv email@provider.com

fi

#### ssmtp.conf

#
# Config file for sSMTP sendmail
#
# The person who gets all mail for userids < 1000
# Make this empty to disable rewriting.
root=postmaster

# The place where the mail goes. The actual machine name is required no
# MX records are consulted. Commonly mailhosts are named mail.domain.com
#mailhub=mail

# Where will the mail seem to come from?
#rewriteDomain=

# The full hostname
hostname=HOSTNAME.locallab

# Are users allowed to set their own From: address?
# YES - Allow the user to specify their own From: address
# NO - Use the system generated From: address
#FromLineOverride=YES

mailhub=smtp.server.com:587
useSTARTTLS=YES
AuthUser=sender@provider.com
AuthPass=passwordstring
TLS_CA_File=/etc/pki/tls/certs/ca-bundle.crt
### it was a gmail with app password


### crontab entry

0 21 * * * /root/restic_jobs/backupscript.sh > /root/restic_jobs/transcript.log 2>&1

Commenti

Post popolari in questo blog

Teams Incoming Webhook deprecated: Use PowerAutomate - Workflow

Mysql operator S3 innodbcluster backup SECRET CONFIG

Fedora - KVM - qemu - Windows 11 guest. error: swtpm at /usr/bin/swtpm does not support TPM 2