Answer the question
In order to leave comments, you need to log in
Hello everyone, can you help me figure out the script for Linux?
The task is this, a network folder is mounted on a remote server into which Backup will be made, after which a copy of the contents of sda is created to a temporary file, we delete the old backup and rename the newly created one. It is necessary to add to the script a check for the presence of a file in the backup folder, if it is missing or there is no access to the shares, then the script ends and tries to start in an hour, if the condition is met, create a record of the same folder in the text file with the date of the backup. Thanks to everyone who will respond.
Now the script looks like
this, and the following error is generated:
Answer the question
In order to leave comments, you need to log in
bs you have from somewhere out of the blue, neither for the network nor for the disk.
Do you understand that you can only make a block-by-block copy from an unmounted device, otherwise the output will be garbage?
rm before mv does not make sense, mv with the -f switch is enough to overwrite.
mv -f old new
Banal syntax. After case there is no esac, after do there is no done. Or is it an incomplete script? To check a file, there is such garbage - it checks for the presence, that it is a file (and not a directory, for example) and that it is not of zero size:
check_fileread()
{
if [ ${#1} -ne 0 ]; then
if [ ! -r $1 ]; then
echo "File $1 cannot read (does not exist, access denied)"
exit 55
elif [ ! -s $1 ]; then
echo "File $1 is empty (has zero size)"
exit 56
fi
fi
}
Eee aaa Eee and it's easier in any way?
test ! -d /var/backup/mysql/last && { mkdir -p /var/backup/mysql/last ; }
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question