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

What is the method of regularly backing up files in Linux operating system?

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

What is the method of regularly backing up files in Linux operating system? I believe many inexperienced people don't know what to do about it. Therefore, this paper summarizes the causes and solutions of the problem. Through this article, I hope you can solve this problem.

For the webmaster, it is very important to develop good backup habits. No matter how good the performance of the American server, there are problems, if the situation is serious, it will cause website data damage and loss, so regular backup of files can effectively ensure the long-term development of the website.

For Linux system American VPS or server, in addition to using some software to backup website files, you can also use Linux command for regular backup, which is very convenient and convenient. This paper simply shares a method.

Note: take the file directory / home/backups/example backup to / home directory as an example

I. create a script

Touch path, file name. sh

Touch / home/backup.sh

Vi / home/backup.sh

Vi / home/backup.sh

II. Content of the script

#! / bin/sh

Mkdir / home/fcc

Create a file (backup path)

Cp-r / home/backups/example / home/fcc

Meaning: the data is stored in the backups directory, backed up to the fcc directory, and the data is copied first, as follows:

Tar-zcpvf / home/backup$ (date +% Y%m%d) .tar.gz / home/fcc

Meaning: package the file fcc where the data is located

Rm-rf / home/fcc

Delete the contents of the file

Find. /-mtime + 20-name'* .tar.gz''- exec rm-rf {} rm-rf {}\

Meaning: delete files under the changed folder for more than 20 days (the number of days can be determined according to the conditions. )

Fourth, execute the script file

Sh / home/backup.sh

Meaning: set timing to execute scripts

Install the cron service

Check service status: service crond status

Modify crontab content

Execute the command: crontab-e

Time to write script after entry: 0 / 5 * / home/backup.sh (time-sharing, day, month and week)

Set to execute the script every 5 days

Save wq

Restart the cron service

Service cron restart

In this way, the files can be backed up through the above simple scheduled backup settings, and the method is still relatively simple. People are using RAKsmart VPS or server.

In the process, you can also follow the above method for backup.

After reading the above, have you mastered the method of regularly backing up files in the Linux operating system? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!

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

Servers

Wechat

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

12
Report