From e1bf0a9c8b8479d62a2562ffbc1c820c6cf8256d Mon Sep 17 00:00:00 2001 From: djshen Date: Tue, 19 Sep 2023 09:27:48 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=20'bash/=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E5=A4=87=E4=BB=BD/file-backup.sh'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bash/文件备份/file-backup.sh | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 bash/文件备份/file-backup.sh diff --git a/bash/文件备份/file-backup.sh b/bash/文件备份/file-backup.sh new file mode 100644 index 0000000..767dd2c --- /dev/null +++ b/bash/文件备份/file-backup.sh @@ -0,0 +1,7 @@ +time=$(date "+%Y-%m-%d_%H:%M:%S") +zipfilename="存储压缩包名字_"$time".tar.gz" +storagepath="压缩包存放目录" +zippath="压缩的目录文件等" +tar -zcvf ${storagepath}/${zipfilename} -C $zippath . +deleteBakDay=8 # 保留多少天的记录 +find $storagepath -name "存储压缩包名字_*.tar.gz" -type f -mtime +${deleteBakDay} -exec rm -rf {} \; > /dev/null 2>&1 \ No newline at end of file