Answer the question
In order to leave comments, you need to log in
Did I write the directory copy script correctly?
Hello!
We need a script that will archive the catalog with images by cron and send it to Yandex disk.
I never really worked with bash, I googled it as best I could!
1. Please see if everything was done correctly, point out the mistakes!?
2. As I understand there are many different shells bash, sh, etc., which one is better to use for everyday tasks?
#!/bin/bash
PATH_TO_MEDIA='/home/andrey/site_ru/project/media'
FILE_PATH="/tmp/$(date "+%Y-%m-%d_%H-%M-%S")_media.tar.gz"
echo "Архивирую медиа каталог \"$PATH_TO_MEDIA\".."
cd $(dirname $PATH_TO_MEDIA)
tar czf $FILE_PATH --exclude='.*' --exclude='cache' $(basename $PATH_TO_MEDIA)
echo "Готово!"
echo "Отправляю на сервер.."
curl --user mail:123 -T "{$FILE_PATH}" https://webdav.yandex.ru/backup/media/
echo "Готово!"
exit 0
Answer the question
In order to leave comments, you need to log in
Does he fulfill the task that you assign to him? So it's written correctly.
On the second question, here is a pretty good article that compares popular shells.
not really cool, because $(date "+%Y-%m-%d_%H-%M-%S" will be different when creating an archive and sending. Because time is running out.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question