Backup

来自Gea-Suan Lin's Wiki
跳转到导航 跳转到搜索

这边会有备份英语:Backup)的一些资料。

范例

这边是利用restic备份到B2上面,需要先初始化restic需要的bucket(不在这篇):

#!/bin/bash

umask 077

export B2_ACCOUNT_ID="x"
export B2_ACCOUNT_KEY="x"
export RESTIC_PASSWORD="x"

# Directory
sudo tar cf - /srv/foo | zstd -19 -cf -T0 -o /tmp/foo.tar.zst --rsyncable
restic -r b2:gslin-backup-kennel backup /tmp/foo.tar.zst
rm /tmp/foo.tar.zst

# MySQL
mysqldump foo | zstd -19 -cf -T0 -o /tmp/foo-mysql.tar.zst --rsyncable
restic -r b2:gslin-backup-kennel backup /tmp/foo-mysql.tar.zst
rm /tmp/foo-mysql.tar.zst

# Prune
restic -r b2:gslin-backup-bucket forget --keep-daily=7 --keep-weekly=4 --keep-monthly=3 --keep-yearly=3
restic -r b2:gslin-backup-bucket prune

这边mysqldump用到的账号密码是在~/.my.cnf内设定:

[client]
user=readonly
password=x

相关连结