当前仓库属于关闭状态,部分功能使用受限,详情请查阅 仓库状态说明
2 Star 2 Fork 2

code4everything / auto_backup
关闭

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

1. 安装扩展源EPEL

yum -y install epel-release

2. 安装PIP

yum -y install python-pip

3. 安装Python第三方扩展库

pip install apscheduler

4. 上传脚本

pscp local_dir user@ip:/remote_dir
# 例:
pscp C:\Users\pantao\Documents\Projects\python\auto_backup\mysql_auto_backup.py root@180.97.80.83:/root/auto_backup
pscp C:\Users\pantao\Documents\Projects\python\auto_backup\config.json root@180.97.80.83:/root/auto_backup

Putty下载地址(pscp命令) 项目地址

5. 修改配置文件 mysql_config.json (请根据实际情况修改)

{
    "nodes": [
        {
            "user": "zhazhapan",
            "password": "zhazhapan",
            "host": "127.0.0.1",
            "dbs": [
                "efo"
            ]
        }
    ],
    "mysqldump": "",
    "path": "/Users/pantao/Desktop/backup",
    "dateFormat": "%Y-%m-%d-%H-%M-%S",
    "expired": "60*60*24*100",
    "schedulerParams": {
        "cron": false,
        "dayOfWeek": "0-6",
        "hour": 15,
        "minute": 27,
        "seconds": 10
    }
}

说明:如果 mysqldump 已添加到环境变量(可直接执行 mysqldump 命令),则设置配置文件中的 mysqldump 值为空; 否则请将 mysqldump 值设置 mysqldump 所在的路径(并在结尾添加一个文件分隔符),比如 /usr/local/mysql-5.7.17-macos10.12-x86_64/bin/

6. 启动脚本,使脚本在后台运行(不受终端影响)

cd /root/auto_backup
setsid python mysql_auto_backup.py
# 或者
nohup python mysql_auto_backup.py &

7. 检测脚本是否运行

ps -ef | grep mysql_auto_backup.py

8. 设置开机自启

  1. 新建自启脚本

    vim auto.sh
  2. 添加内容

    #!/usr/bin/env bash
    cd /root/auto_backup
    setsid python mysql_auto_backup.py
  3. /etc/rc.local 最后一行中添加脚本路径

    /root/auto_backup/auto.sh
MIT License Copyright (c) 2018 潘滔 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

自动定时备份 展开 收起
Python
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
Python
1
https://gitee.com/code4everything/auto_backup.git
git@gitee.com:code4everything/auto_backup.git
code4everything
auto_backup
auto_backup
master

搜索帮助