Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- # Make sure a .vhhash file exists even if empty
- touch .vhhash
- BACKUPTIME=`date +%Y-%m-%d_%T`
- SOURCE=/home/vhserver/.config/unity3d/IronGate/Valheim
- DESTDIR=/mnt/unraidshare/vhbackup
- DESTFILE=backup_$BACKUPTIME.tar.gz
- OLDHASH=`cat .vhhash`
- NEWHASH=`md5sum $SOURCE"/worlds/FSDedicated.db" | awk '{print $1}'`
- if pgrep valheim_server > /dev/null; then
- if [ "$OLDHASH" = "$NEWHASH" ]; then
- echo "World has not changed. Exiting."
- else
- # Create actual backup here
- tar -cpzf $DESTDIR"/"$DESTFILE $SOURCE
- echo $NEWHASH > .vhhash
- # Delete oldest file if there are more than 84
- # (12 backups * 7 days)
- cd $DESTDIR
- ls -1t | tail -n +85 | xargs rm -f
- fi
- else
- echo "Nothing to do. Exiting."
- fi
Add Comment
Please, Sign In to add comment