Skip to content

An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.

fix: mongodb backup

Andras Bacsaif187040b7e2e
diff --git a/app/Jobs/DatabaseBackupJob.php b/app/Jobs/DatabaseBackupJob.php
index 84aad1b6c5..d73474018a 100644
--- a/app/Jobs/DatabaseBackupJob.php
+++ b/app/Jobs/DatabaseBackupJob.php
@@ -175,13 +175,20 @@ class DatabaseBackupJob implements ShouldQueue, ShouldBeEncrypted
$commands[] = "mkdir -p " . $this->backup_dir;
$commands[] = "docker exec $this->container_name mongodump --authenticationDatabase=admin --uri=$url --gzip --archive > $this->backup_location";
} else {
- $collectionsToExclude = str($databaseWithCollections)->after(':')->explode(',');
- $databaseName = str($databaseWithCollections)->before(':');
+ if (str($databaseWithCollections)->contains(':')) {
+ $databaseName = str($databaseWithCollections)->before(':');
+ $collectionsToExclude = str($databaseWithCollections)->after(':')->explode(',');
+ } else {
+ $databaseName = $databaseWithCollections;
+ $collectionsToExclude = collect();
+ }
$commands[] = "mkdir -p " . $this->backup_dir;
- $commands[] = "docker exec $this->container_name mongodump --authenticationDatabase=admin --uri=$url --db $databaseName --gzip --excludeCollection " . $collectionsToExclude->implode(' --excludeCollection ') . " --archive > $this->backup_location";
+ if ($collectionsToExclude->count() === 0) {
+ $commands[] = "docker exec $this->container_name mongodump --authenticationDatabase=admin --uri=$url --db $databaseName --gzip --archive > $this->backup_location";
+ } else {
+ $commands[] = "docker exec $this->container_name mongodump --authenticationDatabase=admin --uri=$url --db $databaseName --gzip --excludeCollection " . $collectionsToExclude->implode(' --excludeCollection ') . " --archive > $this->backup_location";
+ }
}
-
- ray($commands);
$this->backup_output = instant_remote_process($commands, $this->server);
$this->backup_output = trim($this->backup_output);
if ($this->backup_output === '') {