From 278d822726787c53cd893442005152741832a980 Mon Sep 17 00:00:00 2001 From: xiaoz Date: Mon, 12 Sep 2022 13:57:54 +0800 Subject: [PATCH] fix bug --- install_docker_debian.sh | 3 ++- restic_backup.sh | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 restic_backup.sh diff --git a/install_docker_debian.sh b/install_docker_debian.sh index 346ef4d..310bc50 100644 --- a/install_docker_debian.sh +++ b/install_docker_debian.sh @@ -21,10 +21,11 @@ preparation(){ #安装docker install_docker(){ #创建配置文件 + mkdir -p /etc/docker touch /etc/docker/daemon.json #创建存储目录 mkdir -p /data/docker-data - chown -R docker:docker /data/docker-data + #chown -R docker:docker /data/docker-data cat < /etc/docker/daemon.json { "data-root": "/data/docker-data", diff --git a/restic_backup.sh b/restic_backup.sh new file mode 100644 index 0000000..16f2650 --- /dev/null +++ b/restic_backup.sh @@ -0,0 +1,36 @@ +#!/bin/bash + +##### restic备份脚本 ##### +PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/bin:/sbin:/usr/local/mysql/bin +export PATH + +#导入环境变量 +. .env + +myip=`curl -s ip.rss.ink` +new_hostname=${HOSTNAME}_${myip} + +#安装resitc +install_restic(){ + cd /tmp + wget https://wget.ovh/linux/restic_0.13.1_linux_amd64 + mv restic_0.13.1_linux_amd64 /usr/bin/restic + chmod +x /usr/bin/restic +} + +#restic备份 +restic_backup(){ + export B2_ACCOUNT_ID=${B2_ACCOUNT_ID} + export B2_ACCOUNT_KEY=${B2_ACCOUNT_KEY} + #初始化存储 + restic --password-file=./.restic_pass -r b2:${B2_BUCKET_NAME}:/${new_hostname} init + #备份数据 + for mydir in ${BACKUP_DIRS} + do + + restic --password-file=./.restic_pass ${EXCLUDE_DIRS} -r b2:${B2_BUCKET_NAME}:/${new_hostname} --verbose backup ${mydir} + sleep 10 + done +} + +restic_backup \ No newline at end of file