#!/bin/bash
# File Name: backup_linux.sh
# Author: moshan
# mail: mo_shan@yeah.net
# Created Time: 2019-03-12 18:31:01
# Function:
#########################################################################
bachup_dir="/media/moshan/59883a67-d543-41b6-b803-9efa6168e3d7/thinkpad/full_back"
function f_backup()
{
d_bachup_dir="$(date +%F)"
password="$(md5sum <<< "${bachup_dir}/${d_bachup_dir}"|awk '{print $1}')"
[ ! -d "${bachup_dir}/${d_bachup_dir}" ] && mkdir -p ${bachup_dir}/${d_bachup_dir} || exit
s_backup_dir="/data/test_back"
sudo rsync -av ${s_backup_dir}/* ${bachup_dir}/${d_bachup_dir}
if [ $? -eq 0 ]
then
cd ${bachup_dir}
tar -zcf - ${d_bachup_dir} --remove-files|openssl des3 -salt -k ${password} | dd of=${d_bachup_dir}.des3
fi
}
function f_recover()
{
d_recover_dir="${1}"
password="$(md5sum <<< "${bachup_dir}/${d_recover_dir}"|awk '{print $1}')"
[ ! -f "${bachup_dir}/${d_recover_dir}.des3" ] && exit
cd ${bachup_dir}
dd if=${d_recover_dir}.des3 |openssl des3 -d -k ${password}|tar zxf -
}
[ "${1}x" == "backupx" ] && f_backup
[ "${1}x" == "recoverx" ] && f_recover "$(date +%F)"
一键复制
编辑
Web IDE
原始数据
按行查看
历史