我正在创建一个自定义脚本来使用 Clonezilla 运行备份。该脚本按预期工作(到目前为止),但我在变量分配方面遇到了一些麻烦。
变量赋值行 (maxBackups=4) 在当前目录中创建了一个名为“4”的文件,并且 if 测试无法正常工作。
(按照我的理解,使用这种目录计数方法,指向父目录的链接算作一个目录。)
我究竟做错了什么?我知道这很简单...
谢谢
#!/bin/bash
# Automated usb backup script for Clonezilla
# by DRC
# Begin script
# Store date and time for use in folder name
# to a variable called folderName
folderName=$(date +"%Y-%m-%d--%H-%M")
# mount second partition of USB media for storing
# saved image
mount /dev/sdb2 /home/partimag/
# Determine if there are more than 3 directories
# and terminate the script if there are
cd /home/partimag
maxBackups=4
numberOfBackups=$(find -maxdepth 1 -type d | wc -l)
if [ $numberOfBackups > $maxBackups ]; then
echo "The maximum number of backups has been reached."
echo "Plese burn the backups to DVD and remove them"
echo "from the USB key."
echo "Press ENTER to continue and select 'Poweroff'"
echo "from the next menu."
# Wait for the user to press the enter key
read
# If there are three or less backups, a new backup will be made
else
/usr/sbin/ocs-sr -q2 -c -j2 -a -z0 -i 2000 -sc -p true savedisk $folderName sda
fi