2023-03-16 17:27:11 +02: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
|
2023-05-16 19:44:54 +03:00
|
|
|
# E.g. 2023-075TT171900, I don't think change of month matters and these are
|
2023-03-16 17:27:11 +02:00
|
|
|
# going to be small 8MB files anyway so seeing the age at glance is nice.
|
2023-03-19 20:12:12 +02:00
|
|
|
# WARNING: This doesn't handle DST switch although I don't expect to be
|
2023-03-16 17:27:11 +02:00
|
|
|
# playing or running this script during the problem hours
|
2023-05-16 19:44:54 +03:00
|
|
|
cp -arv "$VMCDIR" "$BACKUPDIR/$(date +%Y-%jT%H%M%S)"
|
2023-03-16 17:27:11 +02:00
|
|
|
|
2023-03-18 13:44:05 +02:00
|
|
|
# Samba is fun with permissions
|
2023-03-23 15:57:29 +02:00
|
|
|
chmod -R 777 $VMCDIR/..
|
2023-03-18 13:44:05 +02:00
|
|
|
chmod -R 777 $VMCDIR
|
|
|
|
chmod -R 777 $BACKUPDIR
|
|
|
|
|
2023-03-22 09:08:36 +02:00
|
|
|
# If duperemove is installed, perform FS based deduplication of backups
|
|
|
|
if hash duperemove 2>/dev/null; then
|
2023-05-18 12:41:11 +03:00
|
|
|
# recursive, dedupe, human-readable, hashfile is like ddrescue mapfile
|
|
|
|
duperemove -rdh --hashfile=$BACKUPDIR/duperemove.hashfile $BACKUPDIR/
|
2023-03-22 09:08:36 +02:00
|
|
|
fi
|
|
|
|
|
2023-03-17 21:50:10 +02:00
|
|
|
# Curiosity, show the space used
|
2023-05-16 19:44:54 +03:00
|
|
|
du -hcs --time $BACKUPDIR
|
2023-05-17 14:05:56 +03:00
|
|
|
df -h $BACKUPDIR
|
2023-05-16 19:44:54 +03:00
|
|
|
|
|
|
|
# When the script finished?
|
|
|
|
date "+%Y-%jT%H%M%S"
|
2023-03-17 21:50:10 +02:00
|
|
|
|
2023-03-16 17:27:11 +02:00
|
|
|
set +x
|