宝塔服务器面板,一键全能部署及管理,送你10850元礼包,点我领取

数据安全对一个企业或者站长来说是至关重要的,关乎着其利益和能够正常运行。所以我们要注重对数据安全的保护,而数据备份则是其中非常重要的一步,这是在为我们日后的操作不当或者服务器被攻击时,将损失降到最低做好准备。

对于Linux系统美国服务器来说,我们可以采用Linux命令进行定时备份,这里以RAKsmart美国服务器Linux系统为例给大家介绍下。

注意:这里以文件目录/home/backups/example备份到/home目录下为例

一、创建脚本

touch 路径、文件名.sh

touch /home/backup.sh

vi /home/backup.sh

二、脚本内容

#! /bin/sh

mkdir /home/fcc

创建一个文件(备份路径)

cp -r /home/backups/example /home/fcc

含义:数据存储backups目录,备份到fcc目录下,首先复制数据,如下:

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

含义:将数据所在文件fcc打包

rm -rf /home/fcc

三、删除文件内容

find ./ -mtime +20 -name ‘’*.tar.gz‘’ -exec rm -rf {} rm -rf {} \\;

含义:删除改文件夹下超过20天的文件(天数可以根据条件来决定。)

第四、执行脚本文件

sh /home/backup.sh

含义:设置定时执行脚本

安装cron服务

检查服务状态:service crond status

修改crontab内容

执行命令:crontab -e

进入后写脚本时间:0 0 /5 * /home/backup.sh (分 时 日 月 周)

设置为每5天执行一次脚本

保存wq

重启cron服务

service cron restart

(本文由美国主机侦探原创,转载请注明!)

RAKsmart Linux操作系统定时备份文件教程-风君子博客

微信扫码加好友进群

主机优惠码及时掌握

1

标签:RAKSmart 美国服务器

.entry-tags .tag-links a{text-decoration:none;}
.single #primary .entry-footer .entry-like a{text-decoration: none;}
/*短代码*/
.couponPost{display: flex;flex-direction: row;font-size: 15px;padding: 15px 0px;border-bottom: 1px dashed #ccc;overflow:hidden;}
.couponPost .couponPostRight{margin-left: 20px;overflow: hidden;width: 616px;display: flex;flex-direction: column;justify-content: space-between;}
.couponPost .couponPostLeft{position: relative;overflow:hidden;width:166px;height:130px;}
.couponPostImage{height: 100%;display: flex;border: 1px solid #ccc;border-radius: 5px;}
.couponPostRight h2.title{margin-bottom:0;font-size:16px;}
.couponPostDesc{text-align: justify;}
.couponPostLeft .couponPostImage::before{content: \’促销\’;position: absolute;color: #fff;background-color: red;font-size: 14px;width: 88px;transform: rotate(-45deg);top: 9px;left: -23px;text-align: center;}
.couponPostRight h2.title a{color: #333;text-decoration: none;}
a.linkPost{display: inline-block;color: #E14036;padding: 0px 10px;border: 1px dashed #e14036;background-color: #FFD886;line-height: 20px;}
.couponPostLink a{margin-left:0!important;text-decoration:none;}
.imageNone::before{content:none!important;}