diff options
| -rw-r--r-- | scripts/backup/LICENSE | 8 | ||||
| -rw-r--r-- | scripts/backup/README | 11 | ||||
| -rw-r--r-- | scripts/backup/backup.sh | 20 | ||||
| -rw-r--r-- | scripts/backup/calibre-backup.sh | 4 | ||||
| -rw-r--r-- | scripts/backup/crontab | 2 | ||||
| -rw-r--r-- | scripts/backup/forge-backup.sh | 4 |
6 files changed, 49 insertions, 0 deletions
diff --git a/scripts/backup/LICENSE b/scripts/backup/LICENSE new file mode 100644 index 0000000..18a7e6b --- /dev/null +++ b/scripts/backup/LICENSE @@ -0,0 +1,8 @@ +The MIT License (MIT) +Copyright © 2025 c41ro + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/scripts/backup/README b/scripts/backup/README new file mode 100644 index 0000000..4a245a6 --- /dev/null +++ b/scripts/backup/README @@ -0,0 +1,11 @@ +# backup.sh + +This simply copies a remote directory's contents to a local directory. + +1. Drop this script in your home and make it executable. +2. Create a new ssh keypair and put the private key somewhere only you have access to (this file needs to have 0600 permissions). +3. For every thing you want to backup, create a bash script that sets the REMOTE_LOCATION and BACKUP_DIR variable. +3. Add a new cron job like this `@daily BASH_ENV=$HOME/environment.sh $HOME/backup.sh >> $HOME/backup.log`. + + +License: It's like 10 lines bro. MIT if you must. diff --git a/scripts/backup/backup.sh b/scripts/backup/backup.sh new file mode 100644 index 0000000..df92fe8 --- /dev/null +++ b/scripts/backup/backup.sh @@ -0,0 +1,20 @@ +#!/usr/bin/bash + +# backup.sh - backup something from somewhere else to local + +BACKUP_TIME="$(date +'%Y-%m-%dT%H:%M:%S')" + +: ${BACKUP_DIR:=/home/c41ro/backups} +: ${REMOTE_LOCATION:=/opt/soft-serve/repos} +: ${SSH_KEY_LOCATION:=/home/c41ro/.ssh/backup} +: ${SSH_USER:=bossing} +: ${SSH_HOST:=c41ro.win} +: ${SSH_PORT:=47} + +echo "Starting backup of $REMOTE_LOCATION at $BACKUP_TIME" + +mkdir -p "$BACKUP_DIR/$BACKUP_TIME" + +scp -i "$SSH_KEY_LOCATION" -P "$SSH_PORT" -r "$SSH_USER"@"$SSH_HOST":"$REMOTE_LOCATION"/* "$BACKUP_DIR/$BACKUP_TIME" + +echo "Backup of $REMOTE_LOCATION finished at $(date +'%Y-%m-%dT%H:%M:%S')" diff --git a/scripts/backup/calibre-backup.sh b/scripts/backup/calibre-backup.sh new file mode 100644 index 0000000..aa26a9e --- /dev/null +++ b/scripts/backup/calibre-backup.sh @@ -0,0 +1,4 @@ +#!/usr/bin/bash + +REMOTE_LOCATION="/opt/media/books" +BACKUP_DIR="/home/c41ro/backups/books" diff --git a/scripts/backup/crontab b/scripts/backup/crontab new file mode 100644 index 0000000..55549b6 --- /dev/null +++ b/scripts/backup/crontab @@ -0,0 +1,2 @@ +@daily BASH_ENV=/home/c41ro/forge-backup.sh /home/c41ro/backup.sh >> /home/c41ro/backup.log +@weekly BASH_ENV=/home/c41ro/calibre-backup.sh /home/c41ro/backup.sh >> /home/c41ro/backup.log diff --git a/scripts/backup/forge-backup.sh b/scripts/backup/forge-backup.sh new file mode 100644 index 0000000..ab77a11 --- /dev/null +++ b/scripts/backup/forge-backup.sh @@ -0,0 +1,4 @@ +#!/usr/bin/bash + +REMOTE_LOCATION="/opt/soft-serve/repos" +BACKUP_DIR="/home/c41ro/backups/forge" |
