backup system scripts
backup system via restic backup dav script, remove unneseccary lines
This commit is contained in:
1 parent
845446e1fe
commit
5ec0108117
3 files changed
+64
-43
No files matched your search
@@ -1,43 +0,0 @@
|
||||
#!/bin/bash
|
||||
date="$(date +"%m%d%H")"
|
||||
echo "Start Backup" > /home/lucas/.LOG/log_backup_$date.log
|
||||
find /home/lucas/.LOG/log_backup_* -mtime +12 -type f -delete
|
||||
STARTTIME=$(date +"%T")
|
||||
echo "Starttime: $STARTTIME"
|
||||
sleep 2
|
||||
BACKUP_CAL=true
|
||||
SERVER="https://cloud.someoneslinux.selfhost.eu"
|
||||
TIMESTAMP=$(date +"%Y%m%d")
|
||||
old_cal_bak="$(find /backup/backup_calender_* -mtime +31 -type f)"
|
||||
find /backup/backup_calender_* -mtime +31 -type f -delete
|
||||
backup_cal_OC="/backup/backup_calender_NC_$TIMESTAMP.ics"
|
||||
backup_cal_geb="/backup/backup_calender_geb_$TIMESTAMP.ics"
|
||||
backup_cal_home="/backup/backup_calender_home_$TIMESTAMP.ics"
|
||||
#export WGETRC="/home/lucas/Documents/Dokumente/Projekte/Server/www/curlrc"
|
||||
curl --netrc-file /home/lucas/.netrc -o "$backup_cal_OC" "${SERVER}/remote.php/dav/public-calendars/JtMqiXpm6mdM3yWC/?export"
|
||||
if [ $? -eq 0 ]; then CAL_RET1="nextCloud Calender backup Successfull"; fi
|
||||
curl --netrc-file /home/lucas/.netrc -o "$backup_cal_geb" "${SERVER}/remote.php/dav/public-calendars/gzxSDCXdWqj8MSMP/?export"
|
||||
if [ $? -eq 0 ]; then CAL_RET2="Geburtstags Calender backup Successfull"; fi
|
||||
curl --netrc-file /home/lucas/.netrc -o "$backup_cal_home" "${SERVER}/remote.php/dav/public-calendars/gkx3W9Cpk3eK2W62/?export"
|
||||
if [ $? -eq 0 ]; then CAL_RET3="Haushalts Calender backup Successfull"; fi
|
||||
|
||||
old_cont_bak="$(find /backup/backup_contacts_* -mtime +31 -type f)"
|
||||
find /backup/backup_calender_* -mtime +31 -type f -delete
|
||||
backup_contacts_phone="/backup/backup_contacts_ContactsPhone_$TIMESTAMP.vcf"
|
||||
backup_email_addr="/backup/backup_contacts_EmailAddressen_$TIMESTAMP.vcf"
|
||||
|
||||
curl --netrc-file /home/lucas/.netrc -o "$backup_contacts_phone" "${SERVER}/remote.php/dav/addressbooks/users/syncuser/phonecontacts_shared_by_lucas?export"
|
||||
if [ $? -eq 0 ]; then CON_RET1="nextCloud Contacts Phone backup Successfull"; fi
|
||||
curl --netrc-file /home/lucas/.netrc -o "$backup_email_addr" "${SERVER}/remote.php/dav/addressbooks/users/syncuser/emailcontacts_shared_by_lucas?export"
|
||||
if [ $? -eq 0 ]; then CON_RET2="NextCloud Contacts Email backup Successfull"; fi
|
||||
|
||||
if [ "$old_bak" == "" ]; then
|
||||
old_bak="Nothing older than 83 Days removed"
|
||||
fi
|
||||
if [ "$old_cal_bak" == "" ]; then
|
||||
old_cal_bak="No Calenders removed"
|
||||
fi
|
||||
if [ "$old_cont_bak" == "" ]; then
|
||||
old_cont_bak="No Contacts removed"
|
||||
fi
|
||||
echo "Endtime: $ENDTIME"
|
||||
Executable
+35
@@ -0,0 +1,35 @@
|
||||
#!/bin/bash
|
||||
date="$(date +"%m%d%H")"
|
||||
echo "Start Backup" > /home/lucas/logs/log_backup_$date.log
|
||||
find /home/lucas/logs/log_backup_* -mtime +12 -type f -delete
|
||||
STARTTIME=$(date +"%T")
|
||||
echo "Starttime: $STARTTIME"
|
||||
sleep 2
|
||||
BACKUP_CAL=true
|
||||
SERVER="https://cloud.someoneslinux.selfhost.eu"
|
||||
TIMESTAMP=$(date +"%Y%m%d")
|
||||
BACKUP_DIR="/backup/dav"
|
||||
|
||||
find ${BACKUP_DIR}/backup_calender_* -mtime +31 -type f -delete
|
||||
backup_cal_OC="${BACKUP_DIR}/backup_calender_NC_$TIMESTAMP.ics"
|
||||
backup_cal_geb="${BACKUP_DIR}/backup_calender_geb_$TIMESTAMP.ics"
|
||||
backup_cal_home="${BACKUP_DIR}/backup_calender_home_$TIMESTAMP.ics"
|
||||
|
||||
curl -s --netrc-file /home/lucas/.netrc -o "$backup_cal_OC" "${SERVER}/remote.php/dav/public-calendars/JtMqiXpm6mdM3yWC/?export"
|
||||
if [ $? -eq 0 ]; then CAL_RET1="nextCloud Calender backup Successfull"; fi
|
||||
curl -s --netrc-file /home/lucas/.netrc -o "$backup_cal_geb" "${SERVER}/remote.php/dav/public-calendars/gzxSDCXdWqj8MSMP/?export"
|
||||
if [ $? -eq 0 ]; then CAL_RET2="Geburtstags Calender backup Successfull"; fi
|
||||
curl -s --netrc-file /home/lucas/.netrc -o "$backup_cal_home" "${SERVER}/remote.php/dav/public-calendars/gkx3W9Cpk3eK2W62/?export"
|
||||
if [ $? -eq 0 ]; then CAL_RET3="Haushalts Calender backup Successfull"; fi
|
||||
|
||||
find ${BACKUP_DIR}/backup_contacts_* -mtime +31 -type f
|
||||
|
||||
backup_contacts_phone="${BACKUP_DIR}/backup_contacts_ContactsPhone_$TIMESTAMP.vcf"
|
||||
backup_email_addr="${BACKUP_DIR}/backup_contacts_EmailAddressen_$TIMESTAMP.vcf"
|
||||
|
||||
curl -s --netrc-file /home/lucas/.netrc -o "$backup_contacts_phone" "${SERVER}/remote.php/dav/addressbooks/users/syncuser/phonecontacts_shared_by_lucas?export"
|
||||
if [ $? -eq 0 ]; then CON_RET1="nextCloud Contacts Phone backup Successfull"; fi
|
||||
curl -s --netrc-file /home/lucas/.netrc -o "$backup_email_addr" "${SERVER}/remote.php/dav/addressbooks/users/syncuser/emailcontacts_shared_by_lucas?export"
|
||||
if [ $? -eq 0 ]; then CON_RET2="NextCloud Contacts Email backup Successfull"; fi
|
||||
|
||||
echo "Endtime: $(date +"%T")"
|
||||
Executable
+29
@@ -0,0 +1,29 @@
|
||||
#!/bin/bash
|
||||
LOGFILE="/var/log/restic-backup.log"
|
||||
|
||||
export RESTIC_REPOSITORY=/backup/restic
|
||||
export RESTIC_PASSWORD_FILE=/root/.config/restic/password
|
||||
|
||||
sudo -u lucas /home/lucas/scripts/utils/backup_calender_contacts.sh
|
||||
{
|
||||
echo "========== $(date '+%Y-%m-%d %H:%M:%S') =========="
|
||||
|
||||
restic backup \
|
||||
/docker \
|
||||
/data/audiobookshelf \
|
||||
/data/gitea \
|
||||
/data/navidrome \
|
||||
/data/nextcloud/data/lucas/files \
|
||||
/data/nextcloud/data/Mimi/files \
|
||||
/data/homeassistant \
|
||||
/backup/dav \
|
||||
--exclude-file /root/.config/restic/excludes.txt
|
||||
|
||||
restic forget --prune \
|
||||
--keep-daily 7 \
|
||||
--keep-weekly 4 \
|
||||
--keep-monthly 12
|
||||
|
||||
echo "Backup completed successfully"
|
||||
echo
|
||||
} | tee -a "$LOGFILE"
|
||||
Reference in new issue
Block a user