#!/bin/bash . /usr/local/include/backup-functions/main.sh . /usr/local/include/backup-functions/gdrive.sh . /usr/local/include/backup-functions/config.sh type='Daily' backup_dir='/root/Gdrive/Backup/Notebook' num_of_backup=5 local_days=5 tar_opts+=' -h' tar_exclude='--exclude=*.iso --exclude=*.jpg --exclude=*.zip --exclude=*.rar --exclude=*.7z --exclude=s100/ --exclude=repos/' which flock > /dev/null || { show_error "No flock installed. You need to install flock first."; exit 1;} { flock -n 9 || { show_error "Another copy of ${0##*/} is still running on $myhostname. Lock file $lock_file locked.\n"; exit 1; } test -f $log_file && mv $log_file $log_file.1 { if [ `date +%u` = "7" ]; then type='Weekly'; num_of_backup=4; local_days=1; fi if [ `date +%d` = "01" ]; then type='Monthly'; num_of_backup=6; local_days=1; fi show_notice "Backup started." mkdir -p $backup_dir/$type/$current_date check_free_space $backup_dir && { compress_cfgs $backup_dir/$type/$current_date compress_dir /home/neo/.Desktop $backup_dir/$type/$current_date/Desktop.tar.$compress_ext compress_dir /home/neo/Документы $backup_dir/$type/$current_date/Documents.tar.$compress_ext check_size $backup_dir/$type/$current_date 500M && \ gdrive_upload $backup_dir/$type $current_date && \ gdrive_clean $backup_dir/$type $num_of_backup && \ clean_dir $backup_dir/$type $local_days save_backup_size $backup_dir/$type/$current_date } show_notice "Backup ended." } >> $log_file 2>> >(tee -a $log_file | grep -vE "$stderr_exclude" >&2) test $err -eq 1 && { show_error "Script ${0##*/} failed. Check logs below:\n$( cat $log_file )"; } } 9> $lock_file exit $err;