更新bf工具

This commit is contained in:
huty 2024-03-15 16:23:31 +08:00 committed by huty
parent 99186acc38
commit 4788ee3017

12
bf
View File

@ -90,6 +90,7 @@ generateSHA () {
mkdir -pv $targetsPath
mv $backupFileName'_SHA512' $targetsPath
echo '------------------------------ 备份文件哈希生成成功( 哈希文件见:' $targetsPath ' ------------------------------'
echo '哈希校验方式:'
}
## 使用宿主机内置的 OpenSSL 加密
encryptByHost () {
@ -98,6 +99,9 @@ encryptByHost () {
mv $backupFileName bak_$backupFileName
openssl enc -e -aes256 -a -kfile $encryptPasswordFile -in bak_$backupFileName -out $backupFileName
rm -rf bak_$backupFileName
echo '------------------------------ 使用主机内置 OpenSSL 加密完成! ------------------------------'
echo 'OpenSSL 版本号:' openssl version ' ,解密时请确保版本一致!'
echo '解密命令:' openssl enc -d -aes256 -a -kfile $encryptPasswordFile -in $backupFileName -out 1_$backupFileName
}
## 使用 Docker 运行 OpenSSL 容器加密
encryptByDocker () {
@ -111,6 +115,14 @@ encryptByDocker () {
docker exec -it openssl openssl enc -e -aes256 -a -kfile /data/key -in /data/bak_$backupFileName -out /data/$backupFileName
cp -rpf data/$backupFileName ./
docker rm -f openssl
rm -rf data
echo '------------------------------ 使用 OpenSSL Docker 容器加密完成! ------------------------------'
echo 'Docker 镜像:' $opensslImage
echo '解密命令:'
echo cp -rpf $backupFileName ./data/$backupFileName
echo cp -rpf $encryptPasswordFile ./data/key
echo docker run -dit --name openssl -v ./data:/data $opensslImage
echo docker exec -it openssl openssl enc -d -aes256 -a -kfile /data/key -in /data/$backupFileName -out /data/1_$backupFileName
}
## 加密备份文件
encrypt () {