feat: Updates docker backup script.
This commit is contained in:
@@ -4,8 +4,7 @@ today=$(date +'%F')
|
||||
stackdir="/etc/komodo/stacks"
|
||||
backupdir="/backups"
|
||||
|
||||
services=()
|
||||
readarray -d '' services < <(find "$stackdir" -maxdepth 1 -mindepth 1 -type d)
|
||||
services=($(find "$stackdir" -maxdepth 1 -mindepth 1 -type d))
|
||||
|
||||
# Directories to backup.
|
||||
volumes=(
|
||||
@@ -42,8 +41,10 @@ function copyVolumes() {
|
||||
mkdir "$dir"
|
||||
for volume in "${volumes[@]}"; do
|
||||
# copy only directories.
|
||||
find "$volume" -maxdepth 1 -mindepth 1 -type d -print0 |
|
||||
xargs -0 -I {} cp -r --parents "$volume" "{}"
|
||||
local dirs=($(find "$volume" -maxdepth 1 -mindepth 1 -type d))
|
||||
for v in "${dirs[@]}"; do
|
||||
cp -r --parents "$v" "$dir"
|
||||
done
|
||||
done
|
||||
}
|
||||
|
||||
@@ -58,8 +59,10 @@ function backup() {
|
||||
function cleanBackups() {
|
||||
echo "Removing old backups..."
|
||||
# Remove backups older than 7 days.
|
||||
find "$backupdir" -maxdepth 1 -mindepth 1 -name "*.tar.gz" -mtime +7 -print0 |
|
||||
xargs -0 -I {} rm -rf "{}"
|
||||
local dirs=($(find "$backupdir" -maxdepth 1 -mindepth 1 -name "*.tar.gz" -mtime +7))
|
||||
for dir in "${dirs[@]}"; do
|
||||
rm -rf "$dir"
|
||||
done
|
||||
}
|
||||
|
||||
function main() {
|
||||
|
||||
Reference in New Issue
Block a user