Giter Club home page Giter Club logo

laravel-backup's People

Contributors

adrianmrn avatar alexvanderbist avatar arcanedev-maroc avatar barryvdh avatar blueclock avatar boryn avatar carusogabriel avatar dependabot[bot] avatar drbyte avatar erikn69 avatar freekmurze avatar github-actions[bot] avatar glamorous avatar gummibeer avatar helderneves91 avatar intrepidws avatar joshbonnick avatar juukie avatar laravel-shift avatar mvdnbrk avatar nielsvanpach avatar patinthehat avatar pieterclaerhout avatar ptondereau avatar ricardoramirezr avatar sdkakcy avatar sebastiandedeyne avatar stefanzweifel avatar tylercd100 avatar yushkevichv avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

laravel-backup's Issues

Backup to S3 using Laravel 5 system doesn't appear to work

Trying to backup my site to Amazon S3 doesn't appear to work and throws this error:

[Aws\S3\Exception\BucketAlreadyOwnedByYouException]                                 
  Your previous request to create the named bucket succeeded and you already own it.

Yet, when I run the following code in my application:

Route::any('/', function() {
    Storage::disk('website-backups')->put('help.txt', 'help.txt');

    if(Storage::disk('website-backups')->exists('help.txt'))
        return "Assert true";

    return "Assert this shizzle failed";

});

I assert true, that a file called 'help.txt' was created.

Server down

Everything with this package run great on local environment, but when I upload it to my server - the server go down without error or something just 'error 500'.

Any ideas?

[Feature] mysqldump is not using extended inserts

Hello again!

System is working as smoothly as ever, but I noticed a very significant detail when importing a backed up database: All the insert queries generated by mysqldump are one-by-one. That makes importing even a small 15mb database one long "I'll-grab-a-coffee-then"-session.

Exporting the imported database using, for example, Sequel Pro (which generates one big insert query per table) takes 5 seconds, whereas the original database takes about 2-3 minutes!

This can be easily fixed by adding the --extended-insert parameter to the mysqldump command. However, I would make this optional using the configuration, as some servers might have trouble with such big queries.

More details can bee seen at the official documentation: https://dev.mysql.com/doc/refman/5.1/en/mysqldump.html#option_mysqldump_extended-insert

As always, thanks in advance!

Backup not stored

Hey,
I'm using the follow command to backup my database:
php artisan backup:run --only-db

This is the output I got:
Start backing up Database dumped Start zipping 1 files... Zip created! Start uploading backup to local-filesystem... Backup stored on local-filesystem in file "/home/vagrant/code/inventory.dev/backups/20150720131612.zip" Backup successfully completed

The backup not stored in my local filesystem. The "backups" folder is writeable.

Installation fails (Laravel 5.2)

vagrant@homestead:~/Code/Zugy$ composer require spatie/laravel-backup
Using version ^2.9 for spatie/laravel-backup
./composer.json has been updated
> php artisan clear-compiled
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Installation request for spatie/laravel-backup ^2.9 -> satisfiable by spatie/laravel-backup[2.9.0].
    - Conclusion: remove symfony/finder v3.0.1
    - Conclusion: don't install symfony/finder v3.0.1
    - spatie/laravel-backup 2.9.0 requires symfony/finder ~2.6 -> satisfiable by symfony/finder[v2.6.0, v2.6.1, v2.6.10, v2.6.11, v2.6.12, v2.6.2, v2.6.3, v2.6.4, v2.6.5, v2.6.6, v2.6.7, v2.6.8, v2.6.9, v2.7.0, v2.7.1, v2.7.2, v2.7.3, v2.7.4, v2.7.5, v2.7.6, v2.7.7, v2.7.8, v2.8.0, v2.8.1].
    - Can only install one of: symfony/finder[v2.8.0, v3.0.1].
    - Can only install one of: symfony/finder[v2.8.1, v3.0.1].
    - Can only install one of: symfony/finder[v2.6.0, v3.0.1].
    - Can only install one of: symfony/finder[v2.6.1, v3.0.1].
    - Can only install one of: symfony/finder[v2.6.10, v3.0.1].
    - Can only install one of: symfony/finder[v2.6.11, v3.0.1].
    - Can only install one of: symfony/finder[v2.6.12, v3.0.1].
    - Can only install one of: symfony/finder[v2.6.2, v3.0.1].
    - Can only install one of: symfony/finder[v2.6.3, v3.0.1].
    - Can only install one of: symfony/finder[v2.6.4, v3.0.1].
    - Can only install one of: symfony/finder[v2.6.5, v3.0.1].
    - Can only install one of: symfony/finder[v2.6.6, v3.0.1].
    - Can only install one of: symfony/finder[v2.6.7, v3.0.1].
    - Can only install one of: symfony/finder[v2.6.8, v3.0.1].
    - Can only install one of: symfony/finder[v2.6.9, v3.0.1].
    - Can only install one of: symfony/finder[v2.7.0, v3.0.1].
    - Can only install one of: symfony/finder[v2.7.1, v3.0.1].
    - Can only install one of: symfony/finder[v2.7.2, v3.0.1].
    - Can only install one of: symfony/finder[v2.7.3, v3.0.1].
    - Can only install one of: symfony/finder[v2.7.4, v3.0.1].
    - Can only install one of: symfony/finder[v2.7.5, v3.0.1].
    - Can only install one of: symfony/finder[v2.7.6, v3.0.1].
    - Can only install one of: symfony/finder[v2.7.7, v3.0.1].
    - Can only install one of: symfony/finder[v2.7.8, v3.0.1].
    - Installation request for symfony/finder == 3.0.1.0 -> satisfiable by symfony/finder[v3.0.1].


Installation failed, reverting ./composer.json to its original content.

Restore functionality

This package looks very promising, thanks!

Is there a way to restore a backup of the database with an artisan command?

MySQL Backup does not work when using sockets.

Today, I discovered that the scheduled backups I had on a client's project weren't working quite as intended. Digging through the files, I found the cause of the problem:

mysqldump: Got error: 2002: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) when trying to connect

It seems like the backup script does not pick up the socket configuration I have in my config/database.php:

['unix_socket' => '/tmp/mysql5.sock']

Fixing this would be much appreciated! Thanks for this wonderful package :)

Edit: Maybe this helps: http://stackoverflow.com/questions/15318875/mysqldump-cannot-connect-using-socket

Add filename prefix and suffix support

Hey, thanks for the package and the quick fix last time!

I've just added manual backup creation to my client's project, but would like to distinguish between an automatically (using the scheduler) and a manually created one.
Instead of storing manually ones inside a database or a text file I would like to detect it through the filename.

Would it be possible to add prefix and suffix options to the backup:run command?
The resulting .zip would then look like this: {prefix}20150421000009{suffix}.zip. Adding prefixes would be as simple as running php artisan backup:run --prefix "backup-" --suffix "-manual"

Thanks in advance!

DB zip files are not removed from the /tmp directory.

I'm not sure If I just haven't set up my configuration properly, but I wanted to raise a potential issue / see if I could get some help with this problem I'm having.

I'm using the s3 file storage system, and running the db only backup command on a cron. All of the temporary zip files stored in the system's /tmp directory are never removed.

Seems like line 52 of BackupCommand.php could use a call to delete the $backupZipFile?
I wanted to check if you guys see my problem also.

Thanks!

tmp files bug/feature

We use laravel-backup with an external file system to backup our DB. The package dumps the db file to the systems tmp dir "sys_get_temp_dir()"

But when an external file system fails to connect the files in the tmp dir will stay, maybe there should be build a fail safe to remove the TMP files when file movement fails.

In our case we noticed our SSD getting filled up very fast all of a sudden, after taking a look we had 22GB of tmp DB files because our backup FTP went offline for a couple of hours.

Error getting database server config

Sorry my English is bad.

I edit your code because i have multiple servers configurations, example:

config/database.php
'default' => 'server1',

     'server1' => [
        'driver'    => 'mysql',
        'host'      => '127.0.0.1,
        'database'  => 'db_1',
        'username'  => 'user_1',
        'password'  => 'pass_1',
        'charset'   => 'utf8',
        'collation' => 'utf8_unicode_ci',
        'prefix'    => '',
        'strict'    => false,
    ],

    'server2' => [
        'driver'    => 'mysql',
        'host'      => '127.0.0.1,
        'database'  => 'db_2',
        'username'  => 'user_2',
        'password'  => 'pass_2',
        'charset'   => 'utf8',
        'collation' => 'utf8_unicode_ci',
        'prefix'    => '',
        'strict'    => false,
    ],

Your code:
File: Spatie\Backup\BackupHandlers\Database\DatabaseBackupHandler
$database = $database ?: config('database.default');

In my exaple $database = server1 and $database != "mysql" then error : laravel-backup can only backup mysql databases

My changes:
File: Spatie\Backup\BackupHandlers\Database\DatabaseBackupHandler

$db_server = config('database.default');

$database = $database ?: config('database.connections.' . $db_server . '.driver');

$database = mysql

Backup successfully completed.!!

Laravel 4?

Hi,

is this package limited to Laravel 5 or may there be a way to use it with Laravel 4 too?

Thanks!

Potential timeout when finding files to backup

I'm getting a "Killed" message, when running the command, and no debug info for it

I've updated the timeout to 240 seconds, and its no where near that for the kill.

Is there a timeout on the finding files? Can I bump it up?

When I comment out base_path(), the backup is successful.

'files' =>'include' => [base_path(),],

`
$ time php artisan backup:run -vvv
Start backing up
Database dumped
Determining which files should be backed up...
Killed

real 0m21.718s
user 0m1.948s
sys 0m1.388s
`

To have an idea of how many files there are,
$ find -type f | wc -l
16043

Problem sending the file do Copy/FTP

I using https://github.com/GrahamCampbell/Laravel-Flysystem on my project with Copy and FTP, both are working fine, but when I try to php artisan backup:run (With FTP) I get this message:

[ErrorException]
ftp_connect(): php_network_getaddresses: getaddrinfo failed: Nome ou serviço desconhecido

And with Copy:

[BadMethodCallException]
Call to undefined method League\Flysystem\Filesystem::createDriver

What am I doing wrong? :)

Multiple backups

Hi!

Is it possible to create multiple backups?
I am running a job every night for the db, and one weekly for the whole base_path.

But I want to run a daily backup of uploaded files only. Could this be done with flags or some other solution?

Schedule backup process

As I can see there's an option " clean " to delete backups having 'maxAgeInDays' => 90,
So is there a possibility to set an option " run " each week run the backup for example ?

Problems backing up

Hi!

This plugin have worked great until January 17th. I get the following error:

[2016-01-17 03:02:34] production.ERROR: exception 'Symfony\Component\Debug\Exception\FatalErrorException' with message 'Call to undefined method Spatie\Backup\Commands\BackupCommand::warn()' in /home/forge/domain.com/vendor/spatie/laravel-backup/src/Commands/BackupCommand.php:44

As I can see on line 44, the error message is "The zipfile that will be backupped has a filesize of zero.". The last backup size is 532MB. Is there a limit on backup size?

I am also running a separate backup job with DB only, and there has not been any problems with this.

0 bytes file on S3

Hi, I am using your great plugin with S3 filesystems. From some times when I have 3500 files zipped in backup it fails to upload it on S3 without any error. ZIp file on S3 has 0 bytes. php artisan backup:run doesn't show any error, it returns success.
I have enough space on s3 (it is empty right now)
When I upload only mysql db without files (changed it in config) everything works.

Do you know what could cause it?

Regards

Using S3, not possible to write direct to bucket

I create S3 bucket dedicated for the backup and use IAM to provide permission to write to bucket.

Unfortunately it is not possible to set path='' to tell laravel-backup to write to the root of the bucket. Any slashes are removed and key is detected as being 0 characters long.

All works ok if folder is named but it mandates an extra folder level that otherwise is not required.

filesize of zero

i have some tip in my console, but i didnot kown the reason , can you help me

The zipfile that will be backupped has a filesize of zero.

the question displayed on win 8.1 . but not show on linux platform

the command is php artisan backup:run --only-db

tks!

Mysql Dump fails when running out of memory

It seems like when backing up a database that exceed the PHP memory limit the backup command fails:

FatalErrorException in DatabaseBackupHandler.php line 43: Allowed memory size of 134217728 bytes exhausted (tried to allocate 21925344 bytes)

    in DatabaseBackupHandler.php line 43
    at FatalErrorException->__construct() in HandleExceptions.php line 131
    at HandleExceptions->fatalExceptionFromError() in HandleExceptions.php line 116
    at HandleExceptions->handleShutdown() in HandleExceptions.php line 0
    at file_get_contents() in DatabaseBackupHandler.php line 43
    at DatabaseBackupHandler->getDumpedDatabase() in DatabaseBackupHandler.php line 57
    at DatabaseBackupHandler->getFilesToBeBackedUp() in BackupCommand.php line 63
    at BackupCommand->getAllFilesToBeBackedUp() in BackupCommand.php line 33
    at BackupCommand->fire() in Container.php line 523

The LOC that is responsible for this is if (! $success || file_get_contents($tempFile) == '') { which just seems to check if the file is empty. http://stackoverflow.com/a/4857194/1397894 suggests using filesize() instead.

Can't backup an application that uses read and write database hosts

In my database.php file, my config/database.php file has the following connection specified:

        'mysql'   => [
            'read'      => [
                'host'  => env('DB_HOST_READ') . (('homestead' == env('DB_USERNAME') && 'homestead' != gethostname()) ? ':33060' : '')
            ],
            'write'     => [
                'host'  => env('DB_HOST_WRITE') . (('homestead' == env('DB_USERNAME') && 'homestead' != gethostname()) ? ':33060' : '')
            ],
            'driver'    => 'mysql',
            'database'  => env('DB_DATABASE'),
            'username'  => env('DB_USERNAME'),
            'password'  => env('DB_PASSWORD'),
            'charset'   => 'utf8',
            'collation' => 'utf8_unicode_ci',
            'prefix'    => '',
            'strict'    => false,
        ],

and this results in the following error:

  [Exception]
  Whoops, Undefined index: host

When I change my config/database.php file to:

        'mysql'   => [
            'driver'    => 'mysql',
            'database'  => env('DB_DATABASE'),
            'host'      => env('DB_HOST') . (('homestead' == env('DB_USERNAME') && 'homestead' != gethostname()) ? ':33060' : ''),
            'username'  => env('DB_USERNAME'),
            'password'  => env('DB_PASSWORD'),
            'charset'   => 'utf8',
            'collation' => 'utf8_unicode_ci',
            'prefix'    => '',
            'strict'    => false,
        ],

...it works like a charm. Just something to be aware of.

What is 'path' => 'backups'?

Hey,

Nice package. I use 'path' => 'backups' and my backups are saved in storage/app directory. Will be an option to restore the backups in feature?

Error in db backup

$ php artisan backup:run --only-db
Start backing up
Could not create backup of db -
//vendor/spatie/laravel-backup/src/BackupHandlers/Database/DatabaseBackupHandler.php -
44 -

[Exception]
Could not create backup of db

Routines backup

Hi,
Thanks for developing wonderful tool. Does the database backup includes routines,triggers etc

Please update README.md

Hey,

please update your readme.md file. Some parts are in laravel 4 style:

// config/app.php

'providers' => [
...
'Spatie\Backup\BackupServiceProvider',
...
];

it must be:

// config/app.php

'providers' => [
...
Spatie\Backup\BackupServiceProvider::class,
...
];

Generate daily, weekly and monthly backups

I'd like to know if it would be useful to have the ability to generate and keep daily backups for the last, say, 30 days, and weekly backups for the last 12 weeks and monthly backups for the last 12 months. Of course these numbers should be configurable.

This would allow for less backup storage while still maintaining old backups. How would you guys feel about this and how would you approach this?

use Storage

I have a strange issue, when run artisan backup:run, I've have error, that class Storage not found.
Works only if I change:
use Storage;
to
use Illuminate\Support\Facades\Storage;

Only able to backup one table in the database

Laravel-backup only seems to be able to make a mysql-dump of one of my nine database tables. I'm running Laravel 5 with MySQL (InnoDB) on Homestead. All other files appear to be backed up just fine

/tmp-folder is being filled

Hi!

First of all thanks for your package. It's a great help for me.

My system dumps its database every hour and uploads to S3. It seems the package uses the /tmp folder for temporary files, but doesn't remove them afterwards. This means my drive is slowly filling up with files, eventually eating up all disk space (my db is about 200MB in size).

Can you comment on this? Perhaps the problem lies elsewhere.
I know I can just make a cron job to delete the files, but I thought the problem might exist for others too.

My server setup is a Laravel Forge server (Ubuntu Linux 14.04, 40GB disk on DigitalOcean Amsterdam).

Limit number of backups stored in backup directory

Is is possible to set how many backup files can be stored in the backup directory?

E.g. If i set the total to 5 and i ran a backup when there were already 5 backups in the directory it would automatically delete the oldest backup and create a new backup.

username and password should not be in command line

Big security isssue! This is really not a good idea.

public function dump($destinationFile)
{
    $command = sprintf('%smysqldump --user=%s --password=%s --host=%s --port=%s %s > %s',
        $this->getDumpCommandPath(),
        escapeshellarg($this->user),
        escapeshellarg($this->password),
        escapeshellarg($this->host),
        escapeshellarg($this->port),
        escapeshellarg($this->database),
        escapeshellarg($destinationFile)
    );
    return $this->console->run($command);
}

This will make the username and password show up in the process list. You should never do that. In a shared hosting environment it means other users know your db credentials.

Instead, write a mysql conf file to laravel storage containing the credentials and use it like this:

$command = sprintf(%smysqldump --defaults-extra-file=%s %s > %s',
    $this->getDumpCommandPath(),
    escapeshellarg($confFile)
    escapeshellarg($this->database),
    escapeshellarg($destinationFile)
);

the $confFile could look something like this

[client]
host     = localhost
user     = homestead
password = secret

PS: For extra credits; If you want to make the backup versionable (git) the command should produce the same results for unchanged databases. That only happens if you also use the arguments --skip-extended-insert and --skip-comments.

scheduling backups

based on the documentation, it seems like we have to schedule these on our own.

is it recommended to schedule with the schedule method in the console kernal and hook into schedule:run, or to create a separate cronjob for the backups?

local temporary files not cleaned?

Hi, thanks for your package. I use it to store my backup files on S3. But unfortunately, temporary files are still created on /tmp and not deleted. This quickly saturate my filesystem :(

Email upon failure

In order to know whether a backup has failed, it would be good to be notified of this. This could for example be done via a configurable email address that would receive an email in case of a failure during the backup process.

Would this be something that could be supported by this package via a PR? If so, any input on how to accomplish this would be welcome.

Cron backup

Before to install the package I wanted to know if it was possible to schedule the backup (every day, every hour, etc ..) ?

I'm using digitalocean and I'm on laravel 5.

Kind regards,

Jérémie

How would I go about getting the most recent zip destination?

I don't know if you already thought about this. So far I haven't seen a simple way though. When the backup is done, I want the newly created zip to email to me. When it creates the zip it's done by different date & time. I need the newest zip file destination or just the name. To send it in a attachment.

Thanks for your time and work on this.

Database only backup

Is it possible to have an artisan command that is only for a DB Backup? Like in version 1?

I personally dont need my application backed up (I have it in Github) - I just want to dump my DB and save it locally + S3.

I can imagine other people would want to run the DB backup more frequently - and backup the app less often. So having the ability to run each command separately seems useful...?

In version 2: Could not create backup of db L5.0

Hi freekmurze, sorry to bother you but Im getting this same errors in the local and digital ocean servers with the S3 and local settings, can you please tell me what can be wrong? mysqldump is install

appreciate any help, thanks and cool package can it be automatic with the new options in L5.1?

  1. php artisan backup:run
    Start backing up
    Determining which files should be backed up...
    [ErrorException]
    Invalid argument supplied for foreach()
  2. php artisan backup:run --only-db
    Start backing up
    [Exception]
    Could not create backup of db

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.