Restic

in Technique with 0 comment and 109 read

1 安装

binary

cd ~
curl -LO https://github.com/restic/restic/releases/download/v*.*.*/restic_*.*.*_linux_amd64.bz
bunzip2 restic*
sudo mv restic* /usr/local/bin/restic
sudo chmod a+x /usr/local/bin/restic

ubuntu

apt install restic

centos

yum-config-manager --add-repo https://copr.fedorainfracloud.org/coprs/copart/restic/repo/epel-7/copart-restic-epel-7.repo
yum install restic -y

2 配置文件

vim ~/restic-env
export AWS_ACCESS_KEY_ID=***
export AWS_SECRET_ACCESS_KEY=***
export RESTIC_REPOSITORY="s3:http://s3.com/bucket"
export RESTIC_PASSWORD="***"
chmod 600 restic-env

3 初始化

source ~/restic-env
restic init

4 一般操作

source ~/restic-env

### 备份
restic backup /dir

### 查看
restic snapshots

### 恢复
restic restore 3726gdsc(snapshots ID) --target /dir

5 定时任务

crontab -e
### 每周二晚上四点备份, 并清除三周前的备份, 保留三周内的备份
0 4 * * 2 . ~/restic-env; /usr/bin/restic(or /usr/local/bin/restic) backup -q /dir; /usr/bin/restic forget -q --prune --keep-weekly 3