Compare commits
2 Commits
64c9ec7ab6
...
ad9b8154f4
| Author | SHA1 | Date |
|---|---|---|
|
|
ad9b8154f4 | 5 months ago |
|
|
5b49f1ab5f | 5 months ago |
@ -1,3 +1,16 @@
|
|||||||
# Mount the drive letter, to a location
|
# Mount the drive letter, to a location
|
||||||
sudo mount -t drvfs K: /mnt/k
|
sudo mount -t drvfs K: /mnt/k
|
||||||
# Using K as it's super irregular, so suitable for backup in-case other drives are mounted
|
# Using K as it's super irregular, so suitable for backup in-case other drives are mounted
|
||||||
|
|
||||||
|
# /mnt/c/Users/Nathan/Documents
|
||||||
|
|
||||||
|
/bin/bash /home/nathan/git/scripts/backup/borg/directory_backup.sh -d /mnt/c/Users/Nathan/NAS -b /mnt/k/borg/NAS
|
||||||
|
# \
|
||||||
|
# -r borg_avps \
|
||||||
|
# -R /home/nathan/BACKUP/rn3/cron
|
||||||
|
|
||||||
|
/bin/bash /home/nathan/git/scripts/backup/borg/directory_backup.sh -d /mnt/c/Users/Nathan/bigNAS -b /mnt/k/borg/bigNAS
|
||||||
|
/bin/bash /home/nathan/git/scripts/backup/borg/directory_backup.sh -d /mnt/c/Users/Nathan/git -b /mnt/k/borg/git
|
||||||
|
|
||||||
|
# restore as different user?
|
||||||
|
# borg --bypass-lock [normal command stuff here]
|
||||||
@ -0,0 +1,59 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
# 0 * * * * /home/nathan/Documents/backup.sh
|
||||||
|
|
||||||
|
# Check if the USB is plugged in (Gnome auto-mounts to /run/media)
|
||||||
|
USB="/run/media/$USER/sd_backup";
|
||||||
|
if [[ ! -d $USB ]]; then
|
||||||
|
exit 1 # sd_backup is not plugged in;
|
||||||
|
fi
|
||||||
|
|
||||||
|
USB_DIR="/fedora/borg";
|
||||||
|
|
||||||
|
DIRS="git nas 360ss";
|
||||||
|
BASE_DIR="/home/nathan/Documents/";
|
||||||
|
|
||||||
|
# Basically the code from directory_backup in scripts.git
|
||||||
|
borg_backup (){
|
||||||
|
if [ ! -d "$BACKUP_DIR" ]; then
|
||||||
|
mkdir -p $BACKUP_DIR
|
||||||
|
borg init --encryption=none $BACKUP_DIR
|
||||||
|
fi
|
||||||
|
|
||||||
|
export BORG_REPO=$BACKUP_DIR
|
||||||
|
borg create ::{hostname}-{now} $DIR
|
||||||
|
}
|
||||||
|
borg_prune () {
|
||||||
|
# Keep last 12 hours, 7 days, 4 weeks worth of backups
|
||||||
|
# LESS for local to save storage
|
||||||
|
borg prune \
|
||||||
|
--glob-archives '{hostname}-*' \
|
||||||
|
--keep-hourly 12 \
|
||||||
|
--keep-daily 7 \
|
||||||
|
--keep-weekly 4
|
||||||
|
# Then clear up the disk space of the files removed via prune
|
||||||
|
borg compact
|
||||||
|
}
|
||||||
|
# Also do an rsync, so there's an accessible clone of data on USB
|
||||||
|
# makes it easier to drop things between PCs, but it is a CLONE
|
||||||
|
rsync_backup (){
|
||||||
|
if [ ! -d "$CLONE_DIR" ]; then
|
||||||
|
mkdir -p $CLONE_DIR;
|
||||||
|
fi
|
||||||
|
# avh with --dry-run when testing
|
||||||
|
# Contents of directory for rsync (extra /)
|
||||||
|
rsync -avh $DIR/ $CLONE_DIR \
|
||||||
|
--delete-before
|
||||||
|
}
|
||||||
|
|
||||||
|
for bDir in $DIRS
|
||||||
|
do
|
||||||
|
BACKUP_DIR=$USB$USB_DIR/$bDir;
|
||||||
|
CLONE_DIR=$USB/fedora/rsync/$bDir;
|
||||||
|
DIR=$BASE_DIR$bDir;
|
||||||
|
|
||||||
|
borg_backup
|
||||||
|
borg_prune
|
||||||
|
|
||||||
|
rsync_backup
|
||||||
|
done
|
||||||
|
|
||||||
Loading…
Reference in New Issue