1cbackup
Версия от 12:05, 11 июня 2024; Vovan (обсуждение | вклад)
mkdir ~/1c_backup
cat << 'EOF' > ~/1c_backup/backup.sh #!/bin/bash export LANG=ru_RU.UTF-8 dest="$(dirname $0)/backup__$(date +%Y-%m-%d-%H-%M-%S).dt" cmd="/opt/1cv8t/x86_64/8.3.23.1865/1cv8t" keep="3" # minutes current_unixtime=`date +%s` test_unixtime=$(($current_unixtime-$keep*60)) function backup(){ DISPLAY=:0 ${cmd} config /N "Администратор" /F "/home/student/Документы/InfoBase" /D "test" /DumpIB ${dest} } function rotate_backups(){ filenames_cmd="$(dirname $0)/*.dt" for f in $(/bin/ls $filenames_cmd); do datetime_from_file=`echo ${f} | awk -F '__' {'print $2'} | awk -F '.' {'print $1'}` #2023-12-24-22-01-02 Y=`echo ${datetime_from_file} | awk -F '-' {'print $1'}` M=`echo ${datetime_from_file} | awk -F '-' {'print $2'}` D=`echo ${datetime_from_file} | awk -F '-' {'print $3'}` h=`echo ${datetime_from_file} | awk -F '-' {'print $4'}` m=`echo ${datetime_from_file} | awk -F '-' {'print $5'}` s=`echo ${datetime_from_file} | awk -F '-' {'print $6'}` unixtime_from_file=`date +%s --date="${Y}-${M}-${D} ${h}:${m}:${s}"` if [[ $unixtime_from_file -lt $test_unixtime ]]; then echo "delete file: ${f}" /bin/rm ${f} else echo "keep file: ${f}" fi done } backup rotate_backups EOF