Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to implement VPS Free backup script under linux

2025-03-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)05/31 Report--

Today, I would like to share with you the relevant knowledge of how to achieve VPS free backup script under linux. The content is detailed and the logic is clear. I believe most people still know too much about this, so share this article for your reference. I hope you can get something after reading this article.

The code is as follows:

#! / bin/bash

# set-x

Time= `date +% y% m% d`

# here is the backup mysql

[!-e / backup/sqltmp] & & mkdir-p / backup/sqltmp # create a temporary backup mysql directory

[!-e / backup/backsql] & & mkdir-p / backup/backsql # create a directory where mysql backups are stored

Cd / backup/sqltmp

Sql= `mysqlshow-u username-p password | grep-v + | grep-ev "data | information | mysql | test" | awk {'print $2'} `# query website databases other than system data in mysql database. You can modify them here as needed.

For sqlname in $sql

Do

Mysqldump-u username-p password $sqlname > $sqlname.sql

Done

Tar zcvf backsql.$time.tar.gz * .sql

Rm-rf * .sql

Mv *.. / backsql/.

Cd..

Rm-rf sqltmp

# here is the backup website

[!-e / backup/webtmp] & & mkdir-p / backup/webtmp # create a temporary backup web file directory

[!-e / backup/backweb] & & mkdir-p / backup/backweb # create a directory where web file backups are stored

Cd / backup/webtmp

Tar zcvf backweb.$time.tar.gz / home/*

Mv *.. / backweb/.

Cd..

Rm-rf webtmp

The following is a script for uploading a backup site to the godaddy space via ftp:

The copy code is as follows:

#! / bin/bash

Backsql= `CD / backup/backsql;ls-r backsql* | head-1` # because the latest file is backed up every day

Backweb= `CD / backup/backweb;ls-r backweb* | head-1`

Ftp-n

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.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report