Самый простой backup-скрипт на bash Linux

В этой заметке я покажу пример самого простого бэкап-скрипта на bash Linux.

# This is my backup file - created by 

# here I am setting a time stamp variable which I like to use for logging
TIMESTAMP=`date +%Y%m%d.%H%M`

# here I am setting up the backup directory as a variable

# here I am setting up the directory in which I want to backup, again another variable

# let's create a variable for the backup file name file

# let's create a variable for the log file, let's also name the log file with the filename and timestamp it

# start the backup, create a log file which will record any messages run by this script
echo -e "Starting backup of  $SRC_DIR directory" >> ${LOG}

# compress the directory and files, direct the tar.gz file to your destination directory
tar -vczf ${DEST_DIR}/${FNAME}-${TIMESTAMP}.tar.gz ${SRC_DIR} >> ${LOG}

# end the backup, append to log file created by this script
echo -e "Ending backup of  $SRC_DIR" >> ${LOG}

Сохраняем его в удобном для вас каталоге и задаем выполнение по расписанию. Для этого открываем файл /etc/crontab и в конец добавляем строку:

00 00   * * *   root    sh /home/backup/backup1c.sh

30 комментариев к “Самый простой backup-скрипт на bash Linux

  1. After research a few of the article on your site now, and I absolutely like your means of blogging. I bookmarked it to my bookmark site listing and will be inspecting back quickly. Pls check out my web site as well as well as let me recognize what you think.

  2. I’m amazed, I have to admit. Seldom do I encounter a blog that’s both educative and entertaining, and without a doubt, you’ve hit the nail on the head. The issue is an issue that not enough people are speaking intelligently about. I am very happy that I found this during my search for something concerning this.

  3. There are some intriguing moments in this post yet I don?t recognize if I see every one of them facility to heart. There is some credibility yet I will certainly hold point of view up until I check into it better. Great write-up, many thanks and also we desire extra! Contributed to FeedBurner too

  4. Good article. I learn something extra tough on various blogs daily. It will certainly always be boosting to check out web content from other authors as well as exercise a something from their store. I?d favor to use some with the material on my blog whether you don?t mind. Natually I?ll give you a web link on your web blog. Thanks for sharing.

  5. An impressive share, I just given this onto a coworker that was doing a little analysis on this. And he actually bought me breakfast since I discovered it for him. smile. So let me reword that: Thnx for the treat! But yeah Thnkx for investing the moment to discuss this, I really feel strongly about it as well as enjoy reading more on this topic. Preferably, as you become knowledge, would you mind updating your blog site with even more information? It is highly useful for me. Large thumb up for this blog post!

  6. Hey excellent blog! Does running a blog like this take a massive amount work?
    I’ve very little knowledge of computer programming
    however I was hoping to start my own blog soon. Anyway, should you have any ideas or tips for new blog
    owners please share. I understand this is off subject but
    I just needed to ask. Cheers! 32hvAj4 cheap flights

  7. Does your blog have a contact page? I’m having a tough time locating it but, I’d like to shoot you an e-mail.
    I’ve got some suggestions for your blog you might be interested in hearing.
    Either way, great site and I look forward to seeing it expand over time.

  8. Howdy I am so excited I found your blog page, I really found you by error, while I was researching on Askjeeve for something else, Nonetheless I
    am here now and would just like to say thank you for a remarkable post and a all round exciting blog (I
    also love the theme/design), I don’t have time to read through
    it all at the minute but I have book-marked it and also added in your RSS feeds, so when I have time I will be back to read more,
    Please do keep up the fantastic work.

  9. There are some interesting points in this article however I don?t recognize if I see every one of them center to heart. There is some legitimacy however I will certainly take hold viewpoint up until I consider it even more. Excellent write-up, thanks and we desire a lot more! Added to FeedBurner too

  10. I was really pleased to find this web-site. I intended to many thanks for your time for this terrific read!! I definitely appreciating every little of it and also I have you bookmarked to have a look at new things you post.

  11. Hello there, I discovered your site by the use of Google whilst looking for a related subject, your web site got here
    up, it seems to be great. I’ve bookmarked it in my
    google bookmarks.
    Hi there, simply changed into aware of your weblog thru Google, and located that it’s truly informative.
    I’m gonna be careful for brussels. I will appreciate in case you proceed this
    in future. Lots of other people will probably be benefited
    from your writing. Cheers!

  12. Hmm it appears like your blog ate my first comment (it was super long) so I guess I’ll just sum it up what I submitted and say,
    I’m thoroughly enjoying your blog. I too am
    an aspiring blog blogger but I’m still new
    to the whole thing. Do you have any points for beginner blog
    writers? I’d genuinely appreciate it.

  13. After research a few of the article on your internet site currently, and also I genuinely like your means of blog writing. I bookmarked it to my book mark website listing and will certainly be inspecting back soon. Pls look into my internet site also and also let me understand what you assume.

Оставить ответ

Ваш адрес email не будет опубликован. Обязательные поля помечены *