A
A
Alexey Kostyukov2016-08-03 08:38:34
linux
Alexey Kostyukov, 2016-08-03 08:38:34

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
73d2b29a7cf8474d81c38e05102e3703.JPG
this, and the following error is generated:
28583dfc400d44c8ba91821207e8c4c8.JPG

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Armenian Radio, 2016-08-03
@gbg

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

C
CityCat4, 2016-08-03
@CityCat4

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
}

V
Victor Taran, 2016-08-03
@shambler81

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 question

Ask a Question

731 491 924 answers to any question