Skip to content

Instantly share code, notes, and snippets.

@nero-dv
Last active February 16, 2025 01:58
Show Gist options
  • Save nero-dv/b63b5e555541a4273c422e9c1b242482 to your computer and use it in GitHub Desktop.
Save nero-dv/b63b5e555541a4273c422e9c1b242482 to your computer and use it in GitHub Desktop.
$envFilePath = ".env"
Get-Content $envFilePath | ForEach-Object {
$vol = $_
Set-Variable -Name vol -Value $_ -Scope Global
docker run --rm --quiet --volume ${vol}:/backupdata --volume .\exported:/to_export busybox tar czf /to_export/${vol}.tar.gz /backupdata
if ($?) {
Write-Host "Backup of $vol completed successfully."
}
}
$del = Read-Host "Delete volume created during export? (y/n)"
if ($del -eq "y") {
docker volume rm exported
Write-Host "Volume 'exported' has been deleted."
}
else {
Write-Host "Volume 'exported' has not been deleted."
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment