36 lines
925 B
Bash
36 lines
925 B
Bash
#!/bin/bash
|
|
|
|
RSYNC="/usr/bin/rsync"
|
|
DESTINATION="/mnt/sata/BACKUP/pi_nextcloud/git/"$1
|
|
echo "Erstelle Backup $1 in $DESTINATION"
|
|
|
|
echo "Erstelle Verzeichnis"
|
|
mkdir -p $DESTINATION
|
|
|
|
sleep 1
|
|
|
|
RSYNC_SOURCE="backups@192.168.25.11:/home/git/"
|
|
# ssh-keygen -t rsa
|
|
# ssh-copy-id -i /root/.ssh/id_rsa.pub backups@192.168.25.11
|
|
RSYNC_SSHKEY="/root/.ssh/id_rsa"
|
|
RSYNC_IGNORE="/root/nextcloud.ignore"
|
|
echo "Starte RSYNC mit Passwort aus $RSYNC_SSHKEY"
|
|
rsync -zavx -e 'ssh -i '$RSYNC_SSHKEY' -p22' \
|
|
--rsync-path="$RSYNC" \
|
|
--exclude-from="$RSYNC_IGNORE" \
|
|
--numeric-ids \
|
|
--delete -r $RSYNC_SOURCE $DESTINATION
|
|
echo "RSYNC beendet"
|
|
|
|
sleep 1
|
|
|
|
echo "Erstelle Datenbank Datei"
|
|
mkdir -p $DESTINATION/db
|
|
mysqldump -h 192.168.25.11 --user=backups --password=hieristeinkuglespasswort --all-databases --lock-tables | bzip2 > $DESTINATION/db/database.sql.bz2
|
|
echo "Datenbank gesichert"
|
|
|
|
sleep 1
|
|
|
|
echo "Beende..."
|
|
exit 0
|