Consolidate pipeline scripts under stages
This commit is contained in:
1 parent
bd95f57b6e
commit
cef7a4ac7b
4 files changed
+9
-9
No files matched your search
@@ -9,8 +9,8 @@ logic remains common and can be updated through Git.
|
|||||||
`backup.sh` runs these stages in order:
|
`backup.sh` runs these stages in order:
|
||||||
|
|
||||||
1. `stages/10-containers.sh` — stop, archive, pull, start and verify projects.
|
1. `stages/10-containers.sh` — stop, archive, pull, start and verify projects.
|
||||||
2. `methods/20-rclone.sh` — copy archives to an rclone destination when enabled.
|
2. `stages/20-rclone.sh` — copy archives to an rclone destination when enabled.
|
||||||
3. `methods/30-smb.sh` — copy archives to a mounted SMB share when enabled.
|
3. `stages/30-smb.sh` — copy archives to a mounted SMB share when enabled.
|
||||||
4. `stages/90-prune.sh` — retain the newest configured number of `.zst`
|
4. `stages/90-prune.sh` — retain the newest configured number of `.zst`
|
||||||
archives locally, including legacy `.zst` and current `.tar.zst` names.
|
archives locally, including legacy `.zst` and current `.tar.zst` names.
|
||||||
|
|
||||||
@@ -38,7 +38,7 @@ cd /backupdockerscripts
|
|||||||
sudo cp .env.example .env
|
sudo cp .env.example .env
|
||||||
sudo cp containers.txt containers.local.txt
|
sudo cp containers.txt containers.local.txt
|
||||||
sudo chmod 600 .env
|
sudo chmod 600 .env
|
||||||
sudo chmod +x backup.sh docker-backup.sh dockerbackup_prune.sh stages/*.sh methods/*.sh
|
sudo chmod +x backup.sh stages/*.sh
|
||||||
```
|
```
|
||||||
|
|
||||||
Edit `.env`. Beaver's Docker source is already represented by:
|
Edit `.env`. Beaver's Docker source is already represented by:
|
||||||
@@ -127,8 +127,8 @@ Run individual parts:
|
|||||||
|
|
||||||
```bash
|
```bash
|
||||||
sudo stages/10-containers.sh --dry-run
|
sudo stages/10-containers.sh --dry-run
|
||||||
sudo methods/20-rclone.sh --dry-run --force
|
sudo stages/20-rclone.sh --dry-run --force
|
||||||
sudo methods/30-smb.sh --dry-run --force
|
sudo stages/30-smb.sh --dry-run --force
|
||||||
sudo stages/90-prune.sh --dry-run
|
sudo stages/90-prune.sh --dry-run
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -179,8 +179,8 @@ pipeline lock prevents concurrent runs.
|
|||||||
|
|
||||||
## Adding another backup method
|
## Adding another backup method
|
||||||
|
|
||||||
Add an executable script named `methods/NN-name.sh`, for example
|
Add an executable script named `stages/NN-name.sh`, for example
|
||||||
`methods/40-restic.sh`. It should load `lib/common.sh`, accept `--dry-run`, and
|
`stages/40-restic.sh`. It should load `lib/common.sh`, accept `--dry-run`, and
|
||||||
return a non-zero status on failure. Add its short name to `.env`:
|
return a non-zero status on failure. Add its short name to `.env`:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ while [[ $# -gt 0 ]]; do
|
|||||||
--containers|-f) CONTAINERS_OVERRIDE="${2:?Missing containers file}"; shift ;;
|
--containers|-f) CONTAINERS_OVERRIDE="${2:?Missing containers file}"; shift ;;
|
||||||
-h|--help)
|
-h|--help)
|
||||||
echo "Usage: ${0##*/} [--dry-run] [--containers FILE] [--skip-containers] [--skip-prune]"
|
echo "Usage: ${0##*/} [--dry-run] [--containers FILE] [--skip-containers] [--skip-prune]"
|
||||||
echo "Methods run in BACKUP_METHODS order. Add methods/NN-name.sh and list name in BACKUP_METHODS."
|
echo "Transfer stages run in BACKUP_METHODS order. Add stages/NN-name.sh and list name in BACKUP_METHODS."
|
||||||
exit 0 ;;
|
exit 0 ;;
|
||||||
*) die "Unknown option: $1" 2 ;;
|
*) die "Unknown option: $1" 2 ;;
|
||||||
esac
|
esac
|
||||||
@@ -59,7 +59,7 @@ fi
|
|||||||
method_args=(); (( DRY_RUN )) && method_args+=(--dry-run)
|
method_args=(); (( DRY_RUN )) && method_args+=(--dry-run)
|
||||||
for method in $BACKUP_METHODS; do
|
for method in $BACKUP_METHODS; do
|
||||||
method_script=""
|
method_script=""
|
||||||
while IFS= read -r candidate; do method_script="$candidate"; break; done < <(find "$SCRIPT_DIR/methods" -maxdepth 1 -type f -name "*-${method}.sh" -print | sort)
|
while IFS= read -r candidate; do method_script="$candidate"; break; done < <(find "$SCRIPT_DIR/stages" -maxdepth 1 -type f -name "*-${method}.sh" -print | sort)
|
||||||
[[ -n "$method_script" ]] || die "Configured backup method not found: $method"
|
[[ -n "$method_script" ]] || die "Configured backup method not found: $method"
|
||||||
"$method_script" "${method_args[@]}"
|
"$method_script" "${method_args[@]}"
|
||||||
done
|
done
|
||||||
|
|||||||
File renamed without changes.
File renamed without changes.
Reference in new issue
Block a user