Reputation: 359
As while using Laravel, we have an option to seed our database or create tables anytime, like
class UsersTableSeeder extends Seeder
{
public function run()
{
User::truncate();
User::create([
'username' => 'Junaid',
'email' => '[email protected]',
'password' => '1234'
]);
User::create([
'username' => 'Junaid Farooq',
'email' => '[email protected]',
'password' => '4321'
]);
}
}
we can seed our database anytime, but what if we have a large no of rows in our table, which are not being seeded but added by the users , then how can we put it that way, like a Seeder file so, anytime at anyplace , we can load all those rows through our Seeder File? not asking about to save .SQL file and then import or Export it, But a way to backup them in a Seeder file
Upvotes: 0
Views: 1645
Reputation: 18665
I don't know of any method of backing up the data to a seed file. You can, like you've already said, export and import your data.
There are also a couple of packages available to backup and restore a database.
laravel-backup
, which seems to be a Laravel-specific package that allows you to backup your database and restore it.database-backup
, which is framework agnostic but does come with a Laravel service provider for easier integration with Laravel.Both seem to allow you to backup and restore from Amazon S3. Having used neither I can't say which is better or why. You'll have to try both out and make that decision for yourself.
Upvotes: 2