V
V
Vechkov Alexander2019-08-30 16:35:08
Yandex.Disk
Vechkov Alexander, 2019-08-30 16:35:08

The condition for bash is if there is a “name” folder on the Yandex disk, then do not create a dad. How?

I make a backup of sites through a bash script and through it I throw backups on a Yandex disk. But before that, I need to create a folder with a specific name on the Yandex disk (via the same bash script), and if such a folder already exists, then there is nothing not to create.
I implemented this with two lines:
The first line - creates a folder with the name that I specified
The second line - throws my backup into this folder

curl -X MKCOL --user login:password https://webdav.yandex.ru/backup_sites/name_folder/
curl --user login:password -T /home/2/d008/htdocs/backup/project https://webdav.yandex.ru/backup_sites/name_folder

The problem is this: if the folder already exists, I get an error - "mkdir: resource already exists"
How can I make the folder be created only if it does not exist (and so that this is not considered an error)?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
moropsk, 2019-08-30
@moropsk

Why make it so difficult.
Once with your hands, make folders, let the script fill in what you need.
https://serveradmin.ru/bekap-sayta-wordpress-na-ya...
https://serveradmin.ru/backup-linux-servera-s-pomo...

V
Viktor Taran, 2019-08-30
@shambler81

test ! -d /var/backup/mysql/last && { mkdir -p /var/backup/mysql/last ; }

https://ru.wikipedia.org/wiki/Test

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question