rorenv/backup/backup.sh

45 lines
672 B
Bash
Raw Permalink Normal View History

2023-05-05 12:44:29 +09:00
#!/bin/ash
# Create backup files.
TMP_TARGET=/mnt/backups/backup-$(hostname)-$(date +'%Y-%m-%d-%H-%M-%S').tar
echo $TMP_TARGET
#
# Kopano
#
echo "Kopano"
cd /tmp
tar -cvf $TMP_TARGET.1 \
kopano/var/lib/kopano/attachments
#
# Gitea
#
echo "Gitea"
cd /tmp
tar -cvf $TMP_TARGET.2 \
gitea/data
#
# MySQL
#
echo "MySQL"
cd /tmp
tar -cvf $TMP_TARGET.3 \
mysql/var/lib/mysql
#
# merge tarball.
#
echo "Merge"
head -c -$((512*2)) $TMP_TARGET.1 > $TMP_TARGET
head -c -$((512*2)) $TMP_TARGET.2 >> $TMP_TARGET
head -c -$((512*2)) $TMP_TARGET.3 >> $TMP_TARGET
rm $TMP_TARGET.1 $TMP_TARGET.2 $TMP_TARGET.3
echo "Archive"
gzip $TMP_TARGET
# Finish.
echo "Backed up."