如何使用 phpmyadmin 自动进行数据库备份

发布于 2024-11-19 12:36:55 字数 134 浏览 0 评论 0原文

我目前正在使用 phpmyadmin 导出作为 sql 转储手动进行数据库备份,结果文件名将是 spbkYYMMDD(Y;年 m:月 D:日)。有没有办法自动进行数据库备份,以便我定期获得 sql 转储间隔和文件名应该自动生成相应的。你能解释一下逻辑吗?

I am currently taking database backup manually using phpmyadmin export as a sql dump,the resulted file name will be spbkYYMMDD(Y;year m:month D:day).Is there any way to automate db backup so that i get sql dump for regular intervals and the file name should automatically generated correspondingly .can you explain me the logic.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

别靠近我心 2024-11-26 12:36:56

在 unix shell 中运行 crontab 并创建规则来启动创建数据库备份的进程

 0 0 * * * /usr/local/bin/mysqldump -uLOGIN -PPORT -hHOST -pPASS DBNAME | gzip -c > `date “+\%Y-\%m-\%d”`.gz

另请检查 this

编辑

你只需编写的网络界面,不要以为你能找到现成的代码。但是你需要使用 cron 作业来自动执行一个函数,以便在 UNIX 机器上定期运行。您可以在此处找到有关如何编写 cron 作业的更多信息。所以你现在只需要编写一个Web界面,它从用户那里获取数据并根据输入更改规则(我认为你可以自己做)

Run crontab in unix shell and create the rule to launch process for creating database backup

 0 0 * * * /usr/local/bin/mysqldump -uLOGIN -PPORT -hHOST -pPASS DBNAME | gzip -c > `date “+\%Y-\%m-\%d”`.gz

Also check this

EDIT

The web interface you only have to write, dont think you can find a readymade code for that. But You need to use cron job, to automate a function to run at regular intervals in a unix machine. You can find more info on how to write a cron-job here. So you now, just need to write a web interface, which gets data from user and changes the rule according to the input(Which I think you can do it yourselves)

花开柳相依 2024-11-26 12:36:56

代码将如下所示:

    @echo off
    for /f "tokens=1" %%i in ('date /t') do set DATE_DOW=%%i
    for /f "tokens=2" %%i in ('date /t') do set DATE_DAY=%%i
    for /f %%i in ('echo %date_day:/=-%') do set DATE_DAY=%%i
    for /f %%i in ('time /t') do set DATE_TIME=%%i
    for /f %%i in ('echo %date_time::=-%') do set DATE_TIME=%%i
    "j:\xamppp\bin\mysqldump" -u root -p  --all-databases>j:\backupmysql\%DATE_DAY%_%DATE_TIME%_database.sql

并将其保存为.bat,您可以从任务计划程序运行它

The Code Will be Like This :

    @echo off
    for /f "tokens=1" %%i in ('date /t') do set DATE_DOW=%%i
    for /f "tokens=2" %%i in ('date /t') do set DATE_DAY=%%i
    for /f %%i in ('echo %date_day:/=-%') do set DATE_DAY=%%i
    for /f %%i in ('time /t') do set DATE_TIME=%%i
    for /f %%i in ('echo %date_time::=-%') do set DATE_TIME=%%i
    "j:\xamppp\bin\mysqldump" -u root -p  --all-databases>j:\backupmysql\%DATE_DAY%_%DATE_TIME%_database.sql

and save it as .bat and u can run it from task scheduler

眼眸里的那抹悲凉 2024-11-26 12:36:56

我为这个确切的用例编写了一个快速脚本,因为我无法访问 mysqldump 的控制台,因此自己需要它:

下载: Github:phpmyadmin_sql_backup.py

在您的案例中的用法:

./phpmyadmin_sql_backup.py "https://www.example.com/phpmyadmin_login_page" USERNAME PASSWORD --basename "" --prepend-date --prefix-format "spbk%y%m%d" --overwrite-existing -o OUTPUT_DIRECTORY

希望它被证明是有用的 其他的。

I wrote a quick script for this exact use-case, since I had no access to the console for mysqldump and therefore needed it myself:

Downloads: Github: phpmyadmin_sql_backup.py

Usage in your case:

./phpmyadmin_sql_backup.py "https://www.example.com/phpmyadmin_login_page" USERNAME PASSWORD --basename "" --prepend-date --prefix-format "spbk%y%m%d" --overwrite-existing -o OUTPUT_DIRECTORY

Hopefully it proves to be useful for others.

假面具 2024-11-26 12:36:56

自动化 MySQL 数据库备份的最佳方法是结合使用一些备份软件和 phpmyadmin 实用程序。第二种方法通常具有无需额外付费的优点和不受控制的安全性的缺点,即使用cron实现一些脚本。

就我个人而言,除了 phpMyAdmin 之外,我更喜欢 Handy Backup。请参阅文章链接作为示例。它不是最热门的备份解决方案,但相对便宜且非常稳定。

The best way to automate MySQL DB backup is to use some backup software in conjunction with phpmyadmin utility. The second way, often having an advantage of no extra payment and a disadvantage of uncontrolled security, is implementing some script with cron.

Personally, I prefer Handy Backup in addition to my phpMyAdmin. See the link to an article as an example. It is not hottest backup solution, but relatively cheap and very stable.

_畞蕅 2024-11-26 12:36:56

当您具有管理员权限时,在文件夹中创建 .bat 文件。
下面是一个简单的 .bat 文件

cd "C:\XAMPP\mysql\bin"
mysqldump -hlocalhost -uroot ca > "D:\cash\bkcash\ca\db_%date:~-4,4%%date:~-10,2%%date:~7,2%_%time:~0,2%%time:~3,2%%time:~6,2%.sql"

Create .bat file in a folder when you have admin rights.
down here is a simple .bat file

cd "C:\XAMPP\mysql\bin"
mysqldump -hlocalhost -uroot ca > "D:\cash\bkcash\ca\db_%date:~-4,4%%date:~-10,2%%date:~7,2%_%time:~0,2%%time:~3,2%%time:~6,2%.sql"
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文