Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,8 @@
"psr-4": {
"SourceBroker\\DeployerExtended\\": "src/"
}
},
"replace": {
"sourcebroker/deployer-extended": "self.version"
}
}
8 changes: 6 additions & 2 deletions deployer/file/config/set.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,17 @@
use SourceBroker\DeployerInstance\Instance;
use SourceBroker\DeployerInstance\Configuration;

// Returns path to store file backups on remote instance.
// Returns path to store file backups.
set('file_backup_path', function () {
if (!get('file_backup_path_relative', false)) {
$path = get('deploy_path') . '/.dep/backups';
} else {
$path = get('deploy_path') . '/' . get('file_backup_path_relative');
}
run('[ -d ' . $path . ' ] || mkdir -p ' . $path);
if (empty(get('argument_stage'))) {
runLocally('[ -d ' . $path . ' ] || mkdir -p ' . $path);
} else {
run('[ -d ' . $path . ' ] || mkdir -p ' . $path);
}
return $path;
});
13 changes: 10 additions & 3 deletions deployer/file/task/file_backup.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@

// Read more on https://github.com/sourcebroker/deployer-extended#backup-files
task('file:backup', function () {

if (!empty(get('argument_stage'))) {
$activePath = get('deploy_path') . '/' . (test('[ -L {{deploy_path}}/release ]') ? 'release' : 'current');
run('cd ' . $activePath . ' && {{bin/php}} {{bin/deployer}} file:backup');
return;
}

$signCode = 'e1a803ffea27e6bf3f93bd601dc42077';

$backupFiles = get('file_backup_packages');
Expand All @@ -14,7 +21,7 @@
return;
}

$searchRootPath = get('deploy_path') .'/'. (test('[ -e {{deploy_path}}/current ]') ? 'current' : '');
$searchRootPath = !empty($_ENV['IS_DDEV_PROJECT']) ? '.' : get('deploy_path') . '/' . (testLocally('[ -e {{deploy_path}}/current ]') ? 'current' : '');

foreach ($backupFiles as $package => $filtersGroups) {
if (empty($filtersGroups)) {
Expand Down Expand Up @@ -43,7 +50,7 @@
BASH;

writeln('Creating backup. Package: "' . $package .'" Backup signature: "'. $backupName .'"');
run($command);
runLocally($command);

writeln('Clean old backups');
$command = '
Expand All @@ -54,7 +61,7 @@
fi
';

run($command);
runLocally($command);
}
})
->desc('Backup filtered files / directories');