init repo
This commit is contained in:
commit
125256558b
1
backup/gitea/backups.mysql.passwd
Normal file
1
backup/gitea/backups.mysql.passwd
Normal file
@ -0,0 +1 @@
|
|||||||
|
diesIsteinStarkesPasswort
|
36
backup/gitea/gitea-backup.sh
Normal file
36
backup/gitea/gitea-backup.sh
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
HOST="192.168.25.11"
|
||||||
|
RSYNC="/usr/bin/rsync"
|
||||||
|
DB="gitea"
|
||||||
|
SOURCE="/var/www/html"
|
||||||
|
DESTINATION="/mnt/sata/BACKUP/pi_nextcloud/SCHATTENKOPIE/"$1
|
||||||
|
RSYNC_SSHKEY="/root/.ssh/id_rsa"
|
||||||
|
MYSQL_PASSWD="/root/backups.mysql.passwd"
|
||||||
|
echo "Erstelle Backup $1 in $DESTINATION"
|
||||||
|
|
||||||
|
echo "Erstelle Verzeichnis"
|
||||||
|
mkdir -p $DESTINATION
|
||||||
|
|
||||||
|
sleep 1
|
||||||
|
|
||||||
|
RSYNC_SOURCE="backups@$HOST:$SOURCE"
|
||||||
|
echo "Starte RSYNC mit Passwort aus $RSYNC_SSHKEY"
|
||||||
|
rsync -zavx -e 'ssh -i '$RSYNC_SSHKEY' -p22' \
|
||||||
|
--rsync-path="$RSYNC" \
|
||||||
|
--numeric-ids \
|
||||||
|
--delete -r $RSYNC_SOURCE $DESTINATION
|
||||||
|
echo "RSYNC beendet"
|
||||||
|
|
||||||
|
sleep 1
|
||||||
|
|
||||||
|
echo "Erstelle Datenbank Datei"
|
||||||
|
mkdir -p $DESTINATION/db
|
||||||
|
PASSWD=$(cat "$MYSQL_PASSWD" | tr -d " \t\n\r")
|
||||||
|
mysqldump -h $HOST --user=backups --password=$PASSWD --lock-tables --databases $DB | bzip2 > $DESTINATION/db/database.sql.bz2
|
||||||
|
echo "Datenbank gesichert"
|
||||||
|
|
||||||
|
sleep 1
|
||||||
|
|
||||||
|
echo "Beende..."
|
||||||
|
exit 0
|
50
backup/gitlab/backup-thetown-gitlab.py
Normal file
50
backup/gitlab/backup-thetown-gitlab.py
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
import os
|
||||||
|
import time
|
||||||
|
from gitlab import Gitlab
|
||||||
|
|
||||||
|
URL = "gitlab.com"
|
||||||
|
PRIVATE_TOKEN = ""
|
||||||
|
USERNAME = ""
|
||||||
|
startedTask = time.time()
|
||||||
|
|
||||||
|
gl = Gitlab("https://%s" % URL, PRIVATE_TOKEN)
|
||||||
|
groupsToCheck = ['TheTown']
|
||||||
|
|
||||||
|
gl.auth()
|
||||||
|
|
||||||
|
gitPath = "/mnt/sata/BACKUP/Git/"
|
||||||
|
if not os.path.exists(gitPath):
|
||||||
|
exit("Git Path does not exists!")
|
||||||
|
|
||||||
|
print("Pulling Projects...")
|
||||||
|
pullList = []
|
||||||
|
for grp in gl.groups.list():
|
||||||
|
if [s for s in groupsToCheck if grp.name in s]:
|
||||||
|
projects = grp.projects.list(all=True)
|
||||||
|
for p in projects:
|
||||||
|
path = "%s/%s" % (grp.name, p.name)
|
||||||
|
pullList.append(path)
|
||||||
|
print("Pulled %s Projects..." % len(pullList))
|
||||||
|
|
||||||
|
print("Starting Clone Task...")
|
||||||
|
startedClone = time.time()
|
||||||
|
os.chdir(gitPath)
|
||||||
|
for singleClone in pullList:
|
||||||
|
pPath = gitPath + singleClone
|
||||||
|
print("Check Project State")
|
||||||
|
if not os.path.exists(pPath):
|
||||||
|
print("%s is a new Project. Creating Folder and init Repo..." % singleClone)
|
||||||
|
os.makedirs(pPath)
|
||||||
|
os.chdir(pPath)
|
||||||
|
os.system("git init")
|
||||||
|
else:
|
||||||
|
print("%s project is not new. switching Directory" % singleClone)
|
||||||
|
|
||||||
|
os.chdir(pPath)
|
||||||
|
print("Start Cloning %s" % singleClone)
|
||||||
|
os.system("git pull https://%s:%s@%s/%s.git" % (USERNAME, PRIVATE_TOKEN, URL, singleClone))
|
||||||
|
print("Cloning %s Complete" % singleClone)
|
||||||
|
os.chdir(gitPath)
|
||||||
|
print("Clone Complete. Clone ran %ss..." % (time.time() - startedClone))
|
||||||
|
|
||||||
|
print("Finished. Ran %ss..." % (time.time() - startedTask))
|
1
backup/nextcloud/backups.mysql.passwd
Normal file
1
backup/nextcloud/backups.mysql.passwd
Normal file
@ -0,0 +1 @@
|
|||||||
|
diesIsteinStarkesPasswort
|
35
backup/nextcloud/nextcloud-backup.sh
Normal file
35
backup/nextcloud/nextcloud-backup.sh
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
#!/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
|
4
backup/nextcloud/nextcloud.ignore
Normal file
4
backup/nextcloud/nextcloud.ignore
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
dash/
|
||||||
|
share/
|
||||||
|
phpmyadmin/
|
||||||
|
|
Loading…
Reference in New Issue
Block a user