Download the PHP package tp5er/tp5-databackup without Composer

On this page you can find all versions of the php package tp5er/tp5-databackup. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package tp5-databackup

Latest Stable Version Total Downloads Latest Unstable Version License PHP Version Require

重要的事情说三遍!!!重要的事情说三遍!!!重要的事情说三遍!!!

  1. pkg6都是作者自己一个人在维护,欢迎提交pull request 减少本人的精力
  2. 作者使用的php版本是php7.4,目测写的方法兼容8以上,如果不兼容,可以提交pull request,记得写一下注释哦!!!
  3. 通过队列或命令行的方式,再也不用担心数据备份不完整

使用本类进行数据库备份

使用composer进行安装

composer require tp5er/tp5-databackup

使用方式1: 继承 tp5er\Backup\controller\BackupController

重要的事情说三遍!!!重要的事情说三遍!!!重要的事情说三遍!!!

在thinkphp框架中定义一个控制器,然后继承tp5er\Backup\controller\BackupController,然后跳转到BackupController控制器中查看方法,都是中国人看的懂中国话。

使用方式2: 使用路由route/app.php

通过路由使用案例: \tp5er\Backup\Route::route();

由于页面使用layui渲染的前端页面,你可以参考前端页面自己量身定做,然后使用\tp5er\Backup\Route::api();调用接口也是可以的哦

基础概念

reader:定义读取SQL的方法,目前只支持Mysql,自定义扩展可以实现 tp5er\Backup\reader\ReaderInterface

writer:定义的写入SQL方法,目前只支持File,自定义扩展可以实现 tp5er\Backup\writer\WriterInterface

Factory:定义reader和writer对象初始化

BackupManager:所有的相关操作都在这里

版本修改记录

CHANGELOG.md

提交代码规范

  1. fork一份代码到自己账号下,生成如 test/tp5-databackup
  2. 拉去一个分支 develop ,看个人习惯,无所谓
  3. 将develop提交pull request
  4. 等待作者合并
  5. 定期(当接受到第一个合并请求开始计算一周之内)会打tag,tag规范:2.1.x 作为新方法新类的出现,2.x.x作为对以往的方法和类进行变更甚至是破坏性的变更

分支说明

main 分支 :2.x版本最新代码,tag2.x标签是在该分支进行上

1.x分支 :1.x版本的最新代码,tag1.x标签是在该分支进行上

develop分支:作者的开发分支,主要开发2.x版本的bug

作者案例开发流程

composer create-project topthink/think tp
cd tp
composer require tp5er/tp5-databackup dev-develop
rm -rf vendor/tp5er/tp5-databackup
git clone -b develop [email protected]:pkg6/tp5-databackup.git vendor/tp5er/tp5-databackup

进入vendor/tp5er/tp5-databackup进行修改代码,然后进行提交代码,提交pull request 进行合并到main分支

其他手段进行数据备份还原

mysql常见命令


//备份整个数据库
mysqldump -uroot -hhost -ppassword dbname > backdb.sql
//备份数据库中的某个表
mysqldump -uroot -hhost -ppassword dbname tbname1, tbname2 > backdb.sql
//备份多个数据库
mysqldump -uroot -hhost -ppassword --databases dbname1, dbname2 > backdb.sql
//备份系统中所有数据库
mysqldump -uroot -hhost -ppassword --all-databases > backdb.sql

//恢复
mysql -uroot -p'123456' dbname < backdb.sql 

//远程备份与还原
备份数据库 192.168.3.10 root 123456 test
mysqldump -h 192.168.3.10 -u root -p123456 test > test.sql
还原数据库 192.168.3.11 root 123456 test
mysql -h 192.168.3.11 -P 3306 -u root -p123456 test < test.sql

备份shell脚本

#!/bin/bash

# 1.备份全部数据库的数据和结构
# mysqldump -uroot -p123456 -A > /data/mysqlDump/mydb.sql
# 2.备份全部数据库的结构(加 -d 参数)
# mysqldump -uroot -p123456 -A -d > /data/mysqlDump/mydb.sql
# 3.备份全部数据库的数据(加 -t 参数)
# mysqldump -uroot -p123456 -A -t > /data/mysqlDump/mydb.sql
# 4.备份单个数据库的数据和结构(数据库名mydb)
# mysqldump -uroot-p123456 mydb > /data/mysqlDump/mydb.sql
# 5.备份单个数据库的结构
# mysqldump -uroot -p123456 mydb -d > /data/mysqlDump/mydb.sql
# 6.备份单个数据库的数据
# mysqldump -uroot -p123456 mydb -t > /data/mysqlDump/mydb.sql
# 7.备份多个表的数据和结构(数据,结构的单独备份方法与上同)
# mysqldump -uroot -p123456 mydb t1 t2 > /data/mysqlDump/mydb.sql
# 8.一次备份多个数据库
# mysqldump -uroot -p123456 --databases db1 db2 > /data/mysqlDump/mydb.sql

# 1.在系统命令行中,输入如下实现还原:
# mysql -uroot -p123456 < /data/mysqlDump/mydb.sql
# 2.在登录进入mysql系统中,通过source指令找到对应系统中的文件进行还原:
# mysql> source /data/mysqlDump/mydb.sql

#保存备份个数,备份31天数据
number=31
#备份保存路径
backup_dir=/root/mysqlbackup
#日期
dd=`date +%Y-%m-%d-%H-%M-%S`
#备份工具
tool=mysqldump
#用户名
username=root
#密码
password=123456
#将要备份的数据库
database_name=demo

#如果文件夹不存在则创建
if [ ! -d $backup_dir ];
then     
    mkdir -p $backup_dir;
fi

#简单写法 mysqldump -u root -p123456 users > /root/mysqlbackup/users-$filename.sql
$tool -u $username -p$password $database_name > $backup_dir/$database_name-$dd.sql

#写创建备份日志
echo "create $backup_dir/$database_name-$dd.dupm" >> $backup_dir/log.txt

#找出需要删除的备份
delfile=`ls -l -crt $backup_dir/*.sql | awk '{print $9 }' | head -1`

#判断现在的备份数量是否大于$number
count=`ls -l -crt $backup_dir/*.sql | awk '{print $9 }' | wc -l`

if [ $count -gt $number ]
then
  #删除最早生成的备份,只保留number数量的备份
  rm $delfile
  #写删除文件日志
  echo "delete $delfile" >> $backup_dir/log.txt
fi

All versions of tp5-databackup with dependencies

PHP Build Version
Package Version
Requires php Version >=7.2.5
ext-json Version *
ext-zlib Version *
ext-pdo Version *
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package tp5er/tp5-databackup contains the following files

Loading the files please wait ....