In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
First, create backup.sh script files
#! / bin/shSOURCE_FOLDER=/dataDB_FOLDER=/data/dbBACKUP_FOLDER=/data/backupTM= `date +% Y% m% d% H% M% S`echo start to dump mysql database and backup files at $TM# delete old sql backup filescd $DB_FOLDERrm-rf $DB_FOLDER/*.sql#dump mysql data/usr/bin/mysqldump-h227.0.0.1-uroot-pcz_pims@2018-- single-transaction-- master-data=2-- databases ms > ms-$TM.sqlecho dump db pims_hf as pims_hf-$TM .SQL / usr/bin/mysqldump-h227.0.0.1-uroot-ppass-- single-transaction-- master-data=2-- databases ms_workflow > pims_hf_workflow-$TM.sqlecho dump db ms_workflow as pims_hf_workflow-$TM.sql/usr/bin/mysqldump-h227.0.0.1-uroot-ppass-- single-transaction-- master-data=2-- databases files > files-$TM.sqlecho dump db filesrv as files-$TM.sql# delete backup files which 30 days before than todayfind $BACKUP_ FOLDER/*-type f-mtime + 30-name "* .zip"-exec rm {}\ # compresscd $SOURCE_FOLDERzip-Q-r $BACKUP_FOLDER/db-$TM.zip dbzip-Q-r $BACKUP_FOLDER/files-new.zip filesecho zip $SOURCE_FOLDER files and backup to $BACKUP_FOLDER end# call system mode send notice msg to nailing to notify curl-X POST-d "templateCode=003&content= file backup succeeded, and the backup file is saved to this directory: $BACKUP_FOLDER" http://127.0.0.1:8080/admin/do/notify/dingdingecho-e end backup files at $TM'\ n\ n\ n'
Second, create scheduled tasks
1) enter: crontab-e on the command line and then add the corresponding task, and wq saves and exits.
2) directly edit the / etc/crontab file, namely vi / etc/crontab, and add the corresponding tasks.
Crontab file format:
* command
Minute hour day month week command
Time-sharing, day, month and week order
For example, the backup script is executed at 01:00 every day of every week, and the log is placed in the backup.log file.
0 1 * / bin/sh / home/script/backup.sh > > / home/script/backup.log 2 > & 1
If the test script is running properly, you can execute the test manually
3) query the current user's scheduled tasks.
Summary
The above is the method of automatic backup script of linux server introduced by Xiaobian (mysql, attachment backup). I hope it will be helpful to you. If you have any questions, please leave me a message and the editor will reply to you in time. Thank you very much for your support to the website!
If you think this article is helpful to you, you are welcome to reprint it, please indicate the source, thank you!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.