「Backup」:修訂間差異
创建页面,内容为“== 範例 == == 相關連結 == * restic” |
|||
(未顯示同一使用者於中間所作的 11 次修訂) | |||
第1行: | 第1行: | ||
這邊會有'''備份'''({{lang-en|Backup}})的一些資料。 | |||
== 範例 == | == 範例 == | ||
這邊是利用[[restic]]備份到[[B2]]上面,需要先初始化restic需要的bucket(不在這篇): | |||
<syntaxhighlight lang="bash"> | |||
#!/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 | |||
</syntaxhighlight> | |||
這邊<code>mysqldump</code>用到的帳號密碼是在<code>~/.my.cnf</code>內設定: | |||
<syntaxhighlight lang="ini"> | |||
[client] | |||
user=readonly | |||
password=x | |||
</syntaxhighlight> | |||
== 相關連結 == | == 相關連結 == | ||
* [[B2]] | |||
* [[MySQL]] | |||
* [[restic]] | * [[restic]] |
於 2025年3月30日 (日) 03:23 的最新修訂
這邊會有備份(英語: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