Automated or regular backup of mysql data

后端 未结 2 1023
耶瑟儿~
耶瑟儿~ 2020-11-22 09:19

I want to take regular backups of some tables in my mysql database using / plain php / my second favorite language. I want it to b

2条回答
  •  清歌不尽
    2020-11-22 09:51

    I am suggesting to get database backup by command line utility using script file instead of PHP script.

    Make my.ini file for store configurations

    make file my.ini for default db username and password in root directory of user. so script will take username, password and hostname from this file

    [client]
    user = 
    password = 
    host = 
    

    Create sh file called backup.sh

    #!/bin/sh
    #
    # script for get backup everyday
    
    #change directory to your backup directory
    cd /path_of_your_directory
    #get backup of database of applications
    mysqldump  tmp_db.sql;
    
    #compress it in zip file
    zip app_database-$(date +%Y-%m-%d).sql.zip tmp_db.sql;
    
    #remove  sql file
    rm -rf tmp_db.sql;
    

    Give Executable permission to sh.file

    chmod +x backup.sh
    

    Set Cronjob

    sh //backup.sh >/dev/null 2>&1
    

    Thats all

    Goodluck

提交回复
热议问题