diff --git a/.gitignore b/.gitignore index d436576ff..da248e548 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,8 @@ vendor/ .sass-cache # Grav Specific +backup/* +!backup/.* cache/* !cache/.* assets/* diff --git a/backup/.gitkeep b/backup/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/system/src/Grav/Common/Backup/ZipBackup.php b/system/src/Grav/Common/Backup/ZipBackup.php index cdef16efc..2951cf9bf 100644 --- a/system/src/Grav/Common/Backup/ZipBackup.php +++ b/system/src/Grav/Common/Backup/ZipBackup.php @@ -16,6 +16,7 @@ class ZipBackup protected static $ignore = [ '.git', + 'backup', 'cache', 'images', 'logs' @@ -24,8 +25,11 @@ class ZipBackup public static function backup($destination = null, callable $messager = null) { if (!$destination) { - $destination = self::getGrav()['locator']->findResource('cache://', true); - $destination = $destination . DS . 'tmp/Grav-' . uniqid(); + $destination = self::getGrav()['locator']->findResource('backup://', true); + + if (!$destination) + throw new \RuntimeException('The backup folder is missing.'); + Folder::mkdir($destination); } diff --git a/system/src/Grav/Common/Config/Config.php b/system/src/Grav/Common/Config/Config.php index 1fe373a40..60f443108 100644 --- a/system/src/Grav/Common/Config/Config.php +++ b/system/src/Grav/Common/Config/Config.php @@ -72,6 +72,12 @@ class Config extends Data 'prefixes' => [ '' => ['logs'] ] + ], + 'backup' => [ + 'type' => 'Stream', + 'prefixes' => [ + '' => ['backup'] + ] ] ]; diff --git a/system/src/Grav/Console/Cli/SandboxCommand.php b/system/src/Grav/Console/Cli/SandboxCommand.php index 4d984d219..ef85e42bb 100644 --- a/system/src/Grav/Console/Cli/SandboxCommand.php +++ b/system/src/Grav/Console/Cli/SandboxCommand.php @@ -20,6 +20,7 @@ class SandboxCommand extends Command * @var array */ protected $directories = array( + '/backup', '/cache', '/logs', '/images',