百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
C

CloudBackupBundle

> 编程语言
开源

能够备份数据库并将其上传到云端(Dropbox、Amazon S3、GoogleDrive 等)

196 stars0 点赞2 次浏览
访问官网GitHub

工具介绍

能够备份数据库并将其上传到云端(Dropbox、Amazon S3、GoogleDrive 等)

CloudBackupBundle

This bundle helps you to backup your databases and upload it to the cloud with only one Symfony2 command.

You can :

  • Dump one database
  • Dump all databases
  • Different types of databases can be dumped each time
  • Upload to several Cloud services

Databases supported :

  • MongoDB
  • MySQL
  • PostgreSQL (excluding all_databases option)

Cloud services supported :

  • Dropbox (Dropbox SDK)
  • CloudApp (thanks to CloudAPP-API-PHP-wrapper)
  • Amazon S3 (through KnpGaufretteBundle or OneupFlysystemBundle)
  • Google Drive (thanks to HappyrGoogleSiteAuthenticatorBundle)
  • Rackspace (through OneupFlysystemBundle)

But also :

  • Local (through KnpGaufretteBundle or OneupFlysystemBundle)
  • FTP (through KnpGaufretteBundle or OneupFlysystemBundle)
  • sFTP (through KnpGaufretteBundle or OneupFlysystemBundle)
  • GridFS (through KnpGaufretteBundle or OneupFlysystemBundle)
  • MogileFS (through KnpGaufretteBundle)
  • WebDAV (through OneupFlysystemBundle)

are supported :-)

Compressors supported :

  • Tar - fast and medium effective, don't support password
  • Zip - fast and medium effective, support password
  • 7zip - very slow and very effective, support password

Splitters supported:

  • ZipSplit - split a zipfile into smaller zipfiles

Installation (>=Symfony 2.1)

Composer

Download CloudBackupBundle and its dependencies to the vendor directory. You can use Composer for the automated process:

bash
$ php composer.phar require dizda/cloud-backup-bundle

Composer will install the bundle to vendor/dizda directory.

Adding bundle to your application kernel

php
// app/AppKernel.php

public function registerBundles()
{
    $bundles = array(
        // ...
        new Dizda\CloudBackupBundle\DizdaCloudBackupBundle(),
        // ...
    );
}

Configuration

Here is the default configuration for the bundle:

…

It is recommended to keep real values for logins and passwords in your parameters.yml file, e.g.:

…
yaml
# app/config/parameters.yml
	# ...
    database_driver: pdo_mysql
    database_host: localhost
    database_port: null
    database_name: myDatabase
    database_user: myLogin
    database_password: myDatabasePassword
    # ...
    dizda_cloud_dropbox_token:     myDropboxUser
    dizda_cloud_mongodb_user:     mongodbUser
    dizda_cloud_mongodb_password: mongodbPass
    dizda_cloud_archive_password: ArchivePassword
    # ...

Usage

The bundle adds one command to symfony console: app/console dizda:backup:start which you execute periodically as a cron job. For example the following cron command dumps your database every days at 6am on a server :

# m h  dom mon dow   command
0 6 * * * cd /var/www/yourproject && php app/console --env=prod dizda:backup:start > /dev/null 2>&1

Info : To edit crontab for the user www-data (to prevent permissions error) :

bash
$ crontab -u www-data -e

or simply

bash
$ php app/console --env=prod dizda:backup:start

In addition, using -F or --folder option the folders also will be added to the backup.

Obviously, if some problems occurs during the backup process, you can configure monolog to send you emails.

When working locally or on a staging server, you can configure the bundle to enable restoring. Set restore: true and the following command is available:

bash
$ php app/console dizda:backup:restore --force

Note! Not all processors, clients and databases supports restoring. Backupped files are not restored.

Which archiver do I use?

tar and zip archivers are produce the same size of compressed file, but tar compresses faster. 7z archiver is very slow, but has double effectiveness. tar archiver do not support encryption, other archivers support.

Note Your system may not have the zip and 7z archivers installed. But tar is installed in common case.

Guide to choice:

  • If you don't need password protection and you have enough disk space, the best choice is tar.
  • If you need password protection and you have enough disk space, the best choice is zip.
  • If you haven't enough disk space (or you will do backup often) and you backup only text data (e.g. database dumps), the best choice is 7z.

Note Any archiver good compress text files (and better compress structured texts e.g. sql, css, html/xml). But binary files (images, audio, video) will not be well compressed. If you have small database dump and big binary data, the best choice will be tar or zip.

Comparison of archivers

Uncompressed archive contents sql dump of 42.2M size. This table represents effectiveness of archivers. Third column contents compressed archive file and percent of compression (low is better). Fourth column contents compression time and its ratio (to first line) (low is better).

archiver compression archive size execution time
tar default (6) 8.78M (20.8%) 4.44s (1.00x)
tar best (9) 8.45M (20.0%) 9.89s (2.23x)
zip default (6) 8.78M (20.8%) 5.39s (1.21x)
zip best (9) 8.45M (20.0%) 11.03s (2.48x)
7z default (5) 4.42M (10.5%) 31.06s (7.00x)
7z best (9) 4.24M (10.0%) 38.88s (8.76x)

Capifony integration

If you are using capifony for deployment you can grab the sample task for easier backups.

Add the following task in your deploy.rb file

ruby
namespace :symfony do
    namespace :dizda do
        namespace :backup do
            desc "Upload a backup of your database to cloud service's"
            task :start do
                run "#{try_sudo} sh -c 'cd #{current_release} && #{php_bin} #{symfony_console} dizda:backup:start #{console_options}'"
            end
        end
    end
end

This adds symfony:dizda:backup:start command to capifony. To launch it automatically on deploy you might use:

ruby
# 1) Launches backup right before deploy
before "deploy", "symfony:dizda:backup:start"

# 2) Launches backup after deploy
after "deploy", "symfony:dizda:backup:start"

Report to Deadmanssnitch.com

To be sure your backup scripts are actually run you can report each successful backup to deadmanssnitch.com using DeadmanssnitchBundle.

End

This bundle was inspired from KachkaevDropboxBackupBundle.

Enjoy, PR are welcome !

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

PHP

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月18日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言