Skip to content
This repository has been archived by the owner on Jun 2, 2024. It is now read-only.

Commit

Permalink
Renamed the backup save method to create instead. Updated readme and …
Browse files Browse the repository at this point in the history
…tests.
  • Loading branch information
timothymarois committed Sep 5, 2017
1 parent 17a519b commit 31234ea
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ Here is a list of methods you can use on the database class.
|`flushCache()` | Clears all the cache |
|`truncate()` | Deletes all documents. Alias of `flush(true)` |
|`query()` | Refer to the [Queries](https://github.com/tmarois/Filebase#8-queries) |
|`backup()` | Refer to the [Backups](https://github.com/tmarois/Filebase#10-database-backups) |

Examples

Expand Down Expand Up @@ -400,28 +401,27 @@ Cached queries will only be used if a specific saved cache is less than the expi


## (10) Database Backups
By default you can backup your database using `$db->backup()->save()`, this will create a `.zip` file of your entire database based on your `dir` path.
By default you can backup your database using `$db->backup()->create()`, this will create a `.zip` file of your entire database based on your `dir` path.

### Methods:
These methods can be used when invoking `backup()` on your `Database`.

- `save()` Saves a backup of your database (in your backup location `.zip`)
- `create()` Creates a backup of your database (in your backup location `.zip`)
- `clean()` Purges all existing backups (`.zip` files in your backup location)
- `find()` Returns an `array` of all existing backups (array key by `time()` when backup was created)

**Example:**

```php

// invoke your database
$database = new \Filebase\Database([
'dir' => '/storage/users',
'backupLocation' => '/storage/backup',
]);

// save a new backup of your database
// create a new backup of your database
// will look something like /storage/backup/1504631092.zip
$database->backup()->save();
$database->backup()->create();

// delete all existing backups
$database->backup()->clean();
Expand Down
2 changes: 1 addition & 1 deletion src/Backup.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public function __construct($backupLocation = '', Config $config)
* save()
*
*/
public function save()
public function create()
{
$backupFile = $this->backupLocation.'/'.time().'.zip';

Expand Down
12 changes: 6 additions & 6 deletions tests/BackupTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function testBackupLocationDefault()
}


public function testBackupSave()
public function testBackupCreate()
{
$db = new \Filebase\Database([
'dir' => __DIR__.'/databases/mydatabasetobackup',
Expand All @@ -45,7 +45,7 @@ public function testBackupSave()
$user->save();
}

$file = $db->backup()->save();
$file = $db->backup()->create();

$db->flush(true);

Expand All @@ -69,7 +69,7 @@ public function testBackupFind()
$user->save();
}

$db->backup()->save();
$db->backup()->create();

$backups = $db->backup()->find();

Expand All @@ -94,9 +94,9 @@ public function testBackupFindSort()
$user->save();
}

$db->backup()->save();
$db->backup()->save();
$last = str_replace('.zip','',$db->backup()->save());
$db->backup()->create();
$db->backup()->create();
$last = str_replace('.zip','',$db->backup()->create());

$backups = $db->backup()->find();
$backupCurrent = current($backups);
Expand Down

0 comments on commit 31234ea

Please sign in to comment.