Bup:基于 git packfile 格式,提供快速增量存储、全局重复数据删除,适用于 Linux、FreeBSD、NetBSD、macOS、Solaris 或 Windows(带有 Cygwin 和 WSL)等。
https://gitee.com/mamh-mixed/python-bup/commits/mamh-0.25
- Initialize a backup repository in the specified local directory:
1
| # bup -d /path/to/repository init
|
Prepare a given directory before taking a backup:
1 2
| # bup -d /path/to/repository index /path/to/directory
|
Backup a directory to the repository:
1 2
| # bup -d /path/to/repository save -n backup_name /path/to/directory
|
Show the backup snapshots currently stored in the repository:
1 2
| # bup -d /path/to/repository ls
|
Restore a specific backup snapshot to a target directory:
1 2
| # bup -d /path/to/repository restore -C /path/to/target_directory backup_name
|
下面给出一个实际的使用例子
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
| #!/bin/bash BUP_CMD=${HOME}/bup/bup BUP_REPO_DIR_NAME="gerrit_bup_repo" GERRIT_MIRROR_DIR_NAME="gerrit_local_mirror" GERRIT_MIRROR_DIR=${HOME}/${GERRIT_MIRROR_DIR_NAME} # /home/buildfarm/gerrit_local_mirror
# 要先导出 环境变量 BUP_DIR,设置bup仓库存放的路径, 不然需要使用-d, --bup-dir=BUP_DIR选项设置路径了. 如果都没有 默认路径是 ~/.bup export BUP_DIR=${HOME}/${BUP_REPO_DIR_NAME}/.bup if [ ! -d "${BUP_DIR}" ] then mkdir -p ${BUP_DIR} ${BUP_CMD} init #在index之前还可以执行一下init fi
# 首先执行 rsync 同步 review_site 目录到本地目录 rsync -avP --delete gerrit@10.12.99.60:/home/gerrit/review_site/ ${GERRIT_MIRROR_DIR}/gerrit_60/review_site/
# 在index之前还可以执行一下init,重复执行init没影响的. 先执行 bup index 然后执行 bup save. ${BUP_CMD} init #在index之前还可以执行一下init ${BUP_CMD} index ${GERRIT_MIRROR_DIR}/gerrit_60 ${BUP_CMD} save --strip-path=${GERRIT_MIRROR_DIR} -n gerrit60 ${GERRIT_MIRROR_DIR}/gerrit_60
L_WEEKDAY=$(date +%w) if [[ "$L_WEEKDAY" = "6" ]]; then # PAR2 SHOULD BE INSTALLED TO MAKE RECOVERY BLOCKS USEABLE ${BUP_CMD} fsck --par2-ok
# QUICK VERIFICATION ${BUP_CMD} fsck --quick --jobs=4
# QUICK VERIFICATION WITHOUT PAR2 ${BUP_CMD} fsck --quick --disable-par2 --jobs=4
# GENERATE RECOVERY BLOCKS FOR NEW FILES ${BUP_CMD} fsck -g --jobs=4 fi
|