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

The method of backing up files by linux

2025-04-12 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

First, we need to create a backup script, open the terminal, type touch / home/beifen.sh, and click enter.

After the file is created, enter the file, type vi / home/backup.sh, and click enter

In the open script, enter:

#! / bin/shmkdir / home/beifen# create a temporary file (the path to save the backup) cp-r / home/backups/balalala / home/beifen# data is stored in the backups directory and backed up to the beifen directory So first copy the data to tar-zcPvf / home/backup$ (date +% Y%m%d). Tar.gz / home/beifen # package the folder where the data resides rm-rf / home/beifen/ # delete the temporary file contents find. /-mtime + 30-name "* .tar.gz"-exec rm-rf {}\ # Delete files under the changed folder for more than 30 days

Type sh / home/beifen.sh again in the terminal and click enter to enable the script

Type crontab-e in the terminal, click enter, and then enter 0 0 / 10 * sh / home/beifen.sh, which means that the beifen.sh script is executed every 10 days

These are the details of how to back up files in linux. Please pay more attention to other related articles!

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