aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorMax Bossing <info@maxbossing.de>2025-09-30 18:02:29 +0200
committerMax Bossing <info@maxbossing.de>2025-09-30 18:02:29 +0200
commit91a45232bd36727dca2e7474005e240d518d4c54 (patch)
tree98fac5162ac356123716634284aece8c927f8106 /scripts
init
Diffstat (limited to 'scripts')
-rw-r--r--scripts/git-backup/README10
-rwxr-xr-xscripts/git-backup/backup.sh21
2 files changed, 31 insertions, 0 deletions
diff --git a/scripts/git-backup/README b/scripts/git-backup/README
new file mode 100644
index 0000000..aacf691
--- /dev/null
+++ b/scripts/git-backup/README
@@ -0,0 +1,10 @@
+* git-backup - backup script
+
+This simply copies all git repositories from my git forge (git.c41ro.win) to my local server.
+
+1. Drop this script in /opt/git-backup/ and make it executable.
+2. Create a new ssh keypair and put the private key under /opt/git-backup/ssh-key (this file needs to have 0600 permissions).
+3. Add a new cron job like this `@daily /opt/git-backup/backup.sh >> /opt/git-backup/backup.sh`.
+
+
+License: It's like 10 lines bro. MIT if you must.
diff --git a/scripts/git-backup/backup.sh b/scripts/git-backup/backup.sh
new file mode 100755
index 0000000..320cb3b
--- /dev/null
+++ b/scripts/git-backup/backup.sh
@@ -0,0 +1,21 @@
+#!/usr/bin/bash
+
+# backup.sh - backup git repositories from somewhere else to local
+
+BACKUP_TIME="$(date +'%Y-%m-%dT%H:%M:%S')"
+BACKUP_DIR="/opt/git-backup/backup"
+
+REPO_LOCATION="/opt/soft-serve/repos"
+
+SSH_KEY_LOCATION="/opt/git-backup/ssh-key"
+SSH_USER="bossing"
+SSH_HOST="c41ro.win"
+SSH_PORT="47"
+
+echo "Starting backup at $BACKUP_TIME"
+
+mkdir -p "$BACKUP_DIR/$BACKUP_TIME"
+
+scp -i "$SSH_KEY_LOCATION" -P "$SSH_PORT" -r "$SSH_USER"@"$SSH_HOST":"$REPO_LOCATION"/* "$BACKUP_DIR/$BACKUP_TIME"
+
+echo "Backup finished at $(date +'%Y-%m-%dT%H:%M:%S')"