加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
backup.sh 1.54 KB
一键复制 编辑 原始数据 按行查看 历史
fnlp 提交于 2022-09-07 03:21 . 一些名称上的修改
#!/bin/zsh
# A script to perform incremental backups using rsync
set -o errexit
set -o nounset
set -o pipefail
BACKUP_ROOT="/source/backup"
DATETIME="$(date '+%Y-%m-%d_%H:%M:%S')"
# BACKUP latex_data-sharelatex_data
SOURCE_DIR="/home/fnlp/latex_data/sharelatex_data"
BACKUP_DIR="${BACKUP_ROOT}/latex_data/sharelatex_data"
mkdir -p "${BACKUP_DIR}"
BACKUP_PATH="${BACKUP_DIR}/${DATETIME}"
LATEST_LINK="${BACKUP_DIR}/latest"
rsync -av --delete \
"${SOURCE_DIR}/" \
--link-dest "${LATEST_LINK}" \
--exclude=".cache" \
"${BACKUP_PATH}"
rm -rf "${LATEST_LINK}"
ln -s "${BACKUP_PATH}" "${LATEST_LINK}"
# BACKUP latex_data-mongodb
docker exec latex_mongo /bin/bash -c "mongodump -o /data/db/backup"
SOURCE_DIR="/home/fnlp/latex_data/mongo_data/backup"
BACKUP_DIR="${BACKUP_ROOT}/latex_data/mongodb"
mkdir -p "${BACKUP_DIR}"
BACKUP_PATH="${BACKUP_DIR}/${DATETIME}"
LATEST_LINK="${BACKUP_DIR}/latest"
rsync -av --delete \
"${SOURCE_DIR}/" \
--link-dest "${LATEST_LINK}" \
--exclude=".cache" \
"${BACKUP_PATH}"
rm -rf "${LATEST_LINK}"
ln -s "${BACKUP_PATH}" "${LATEST_LINK}"
# BACKUP mongo4
docker exec mongo4 /bin/bash -c "mongodump -o /data/db/backup --username ${DB_USER} --password ${DB_PASSWORD}"
SOURCE_DIR="/home/fnlp/mongo4/backup"
BACKUP_DIR="${BACKUP_ROOT}/mongo4"
mkdir -p "${BACKUP_DIR}"
BACKUP_PATH="${BACKUP_DIR}/${DATETIME}"
LATEST_LINK="${BACKUP_DIR}/latest"
rsync -av --delete \
"${SOURCE_DIR}/" \
--link-dest "${LATEST_LINK}" \
--exclude=".cache" \
"${BACKUP_PATH}"
rm -rf "${LATEST_LINK}"
ln -s "${BACKUP_PATH}" "${LATEST_LINK}"
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化