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