gist/gayming/playstation2/backup-ops2l-vmc.bash

34 lines
1002 B
Bash
Raw Permalink Normal View History

2023-03-16 16:27:11 +01:00
#!/usr/bin/env bash
# This is just a simple script to backup VMCs in case something goes wrong
set -x
VMCDIR=~/PS2/VMC
BACKUPDIR=~/PS2-VMC-backups
mkdir -p $BACKUPDIR
# E.g. 2023-075TT171900, I don't think change of month matters and these are
2023-03-16 16:27:11 +01:00
# going to be small 8MB files anyway so seeing the age at glance is nice.
# WARNING: This doesn't handle DST switch although I don't expect to be
2023-03-16 16:27:11 +01:00
# playing or running this script during the problem hours
cp -arv "$VMCDIR" "$BACKUPDIR/$(date +%Y-%jT%H%M%S)"
2023-03-16 16:27:11 +01:00
# Samba is fun with permissions
2024-10-04 18:17:49 +02:00
chmod -Rv 777 $VMCDIR/..
chmod -Rv 777 $VMCDIR
chmod -Rv 777 $BACKUPDIR
# If duperemove is installed, perform FS based deduplication of backups
2024-06-11 19:58:27 +02:00
if hash duperemove 2> /dev/null; then
# recursive, dedupe, human-readable, hashfile is like ddrescue mapfile
duperemove -rdh --hashfile=$BACKUPDIR/duperemove.hashfile $BACKUPDIR/
fi
# Curiosity, show the space used
du -hcs --time $BACKUPDIR
df -h $BACKUPDIR
# When the script finished?
date "+%Y-%jT%H%M%S"
2023-03-16 16:27:11 +01:00
set +x