diff --git a/borg-database-backup.sh b/borg-database-backup.sh deleted file mode 100644 index 65653d5..0000000 --- a/borg-database-backup.sh +++ /dev/null @@ -1,53 +0,0 @@ -#!/bin/sh - -# Borg repo location -REPOSITORY=/var/backup/database.borg/ -# Example of remote repo -# REPOSITORY=ssh://backuper@192.168.1.100/var/backup/database.borg/ - -borgDoBackup() { - - sudo -u postgres pg_dumpall > /var/backups/posgresql.sql - borg create -v --stats --compression zlib,6 $REPOSITORY::`date +%Y-%m-%d-%H:%M` /var/backups/posgresql.sql - rm /var/backups/posgresql.sql - borg prune -v $REPOSITORY --keep-daily=3 --keep-weekly=2 --keep-monthly=12 - echo "`date +[%F/%T]` Done!" - -} - -repoid=$(grep "id" $REPOSITORY/config | awk '{print $3}') -procid=$(pgrep borg | tail -1) - -if [ -d $REPOSITORY/lock.exclusive ] || [ -d /root/.cache/borg/$repoid/lock.exclusive ]; then - - if [ ! -z $procid ]; then - - echo "`date +[%F/%T]` Seems like the borg repo is busy at the moment, I will try again in 30 min" - at now + 30 minutes -f $0 - exit - - else - - if [ -d $REPOSITORY/lock.exclusive ]; then - - rm -r $REPOSITORY/lock.* - - fi - if [ -d /root/.cache/borg/$repoid/lock.exclusive ]; then - - rm -r /root/.cache/borg/$repoid/lock.* - - fi - - borgDoBackup - - fi - -else - - borgDoBackup - -fi - - -exit \ No newline at end of file diff --git a/borg-file-backup.sh b/borg-file-backup.sh index 3d9c2dd..8ddf4ab 100644 --- a/borg-file-backup.sh +++ b/borg-file-backup.sh @@ -1,53 +1,15 @@ -#!/bin/sh +#!/bin/bash # Borg repo location REPOSITORY=/var/backup/files.borg/ # Example of remote repo # REPOSITORY=ssh://backuper@192.168.1.100/var/backup/files.borg/ - -borgDoBackup() { - - echo "`date +[%F/%T]` Starting the backup" - borg create -v --compression lzma,6 --stats $REPOSITORY::`date +%Y-%m-%d-%H:%M` /etc/ /var/www/ /var/spool/ --exclude=*.log - borg prune -v $REPOSITORY --keep-daily=3 --keep-weekly=2 --keep-monthly=12 - echo "`date +[%F/%T]` Done!" - - -} - -repoid=$(grep "id" $REPOSITORY/config | awk '{print $3}') -procid=$(pgrep borg | tail -1) - -if [ -d $REPOSITORY/lock.exclusive ] || [ -d /root/.cache/borg/$repoid/lock.exclusive ]; then - - if [ ! -z $procid ]; then - - echo "`date +[%F/%T]` Seems like the borg repo is busy at the moment, I will try again in 30 min" - at now + 30 minutes -f $0 - exit - - else - - if [ -d $REPOSITORY/lock.exclusive ]; then - - rm -r $REPOSITORY/lock.* - - fi - if [ -d /root/.cache/borg/$repoid/lock.exclusive ]; then - - rm -r /root/.cache/borg/$repoid/lock.* - - fi - - borgDoBackup - - fi - -else - - borgDoBackup - -fi +echo "`date +[%F/%T]` Starting the backup" +# Create backup +borg create -v --compression lzma,6 --stats $REPOSITORY::$(date +%Y-%m-%d-%H:%M) /etc/ /var/www/ /var/spool/ --exclude=*.log +# Clean old backups +borg prune -v $REPOSITORY --keep-daily=3 --keep-weekly=2 --keep-monthly=12 +echo "`date +[%F/%T]` Done!" exit diff --git a/borg-postgresql-backup.sh b/borg-postgresql-backup.sh new file mode 100644 index 0000000..e19d9fb --- /dev/null +++ b/borg-postgresql-backup.sh @@ -0,0 +1,17 @@ +#!/bin/sh + +# Borg repo location +REPOSITORY=/var/backup/database.borg/ +# Example of remote repo +# REPOSITORY=ssh://backuper@192.168.1.100/var/backup/database.borg/ + +# Dump all postgres databases to file +sudo -u postgres pg_dumpall > /tmp/posgresql.sql +# Backup the sql file +borg create -v --stats --compression zlib,6 $REPOSITORY::$(date +%Y-%m-%d-%H:%M) /tmp/posgresql.sql +rm /tmp/posgresql.sql +# Delete old backups +borg prune -v $REPOSITORY --keep-daily=3 --keep-weekly=2 --keep-monthly=12 +echo "`date +[%F/%T]` Done!" + +exit diff --git a/borg-remote-maintainance.sh b/borg-remote-maintainance.sh index 3c0768d..899938c 100644 --- a/borg-remote-maintainance.sh +++ b/borg-remote-maintainance.sh @@ -1,5 +1,6 @@ #!/bin/bash +# Ment to be run on a remote backup server to run prune on all repos borgRepos=$(find ~/path/to/backups/ -type d -name "*.borg") for REPOSITORY in ${borgRepos}; do @@ -7,4 +8,4 @@ for REPOSITORY in ${borgRepos}; do done -exit \ No newline at end of file +exit diff --git a/cloudflare-ddns.sh b/cloudflare-ddns.sh index 91276b7..fb88646 100644 --- a/cloudflare-ddns.sh +++ b/cloudflare-ddns.sh @@ -20,8 +20,6 @@ if host $dnsrecord 1.1.1.1 | grep "has address" | grep "$ip"; then exit fi -# if here, the dns record needs updating - # get the zone id for the requested zone zoneid=$(curl -s -X GET "https://api.cloudflare.com/client/v4/zones?name=$zone&status=active" \ -H "X-Auth-Email: $cloudflare_auth_email" \