kopia init
This commit is contained in:
parent
ad0f20f17a
commit
279f26c23d
2 changed files with 83 additions and 3 deletions
78
kopia/docker-compose-init.yml
Normal file
78
kopia/docker-compose-init.yml
Normal file
|
|
@ -0,0 +1,78 @@
|
|||
# Run once: docker compose -f docker-compose-init.yml up --build --force-recreate
|
||||
|
||||
services:
|
||||
kopia_init:
|
||||
image: kopia/kopia:latest
|
||||
container_name: kopia_init
|
||||
# Use the passwords from .env
|
||||
environment:
|
||||
- KOPIA_REPOSITORY_PASSWORD=${KOPIA_REPOSITORY_PASSWORD}
|
||||
- PUID=1000
|
||||
- PGID=1000
|
||||
|
||||
# Volumes MUST match the server setup so the repository is initialized in the correct place.
|
||||
volumes:
|
||||
- kopia_config:/app/config
|
||||
- kopia_cache:/app/cache
|
||||
- kopia_logs:/app/logs
|
||||
- g:/kopia-backups:/app/repository # CRITICAL: This is where the repo will be created
|
||||
|
||||
# --- YOUR SOURCE DATA ---
|
||||
# Maps your host's E:\installers and H:\immich-photos to specific paths inside the container.
|
||||
# ':ro' (read-only) is a safety best practice.
|
||||
- e:/installers:/source/installers:ro
|
||||
- h:/immich-photos:/source/immich-photos:ro
|
||||
|
||||
# Override the default Kopia ENTRYPOINT to use the standard shell.
|
||||
entrypoint: /bin/sh
|
||||
|
||||
# This command now runs 4 steps sequentially:
|
||||
# 1. Create the repository.
|
||||
# 2. Connect to it (so subsequent commands work).
|
||||
# 3. SET POLICY for /source/installers (12h interval + retention).
|
||||
# 4. SET POLICY for /source/immich-photos (12h interval + retention).
|
||||
command:
|
||||
- -c
|
||||
- |
|
||||
# 1. Create the Kopia Repository
|
||||
echo 'Creating new Kopia repository at /app/repository...'
|
||||
kopia repository create filesystem \
|
||||
--path=/app/repository \
|
||||
--password=${KOPIA_REPOSITORY_PASSWORD} \
|
||||
&& \
|
||||
# 2. Explicitly connect to the repository non-interactively.
|
||||
# This is CRITICAL for the policy commands to work.
|
||||
echo 'Connecting to repository non-interactively...' && \
|
||||
kopia repository connect filesystem \
|
||||
--path=/app/repository \
|
||||
--password=${KOPIA_REPOSITORY_PASSWORD} \
|
||||
&& \
|
||||
# 3. SET POLICY for installers (Schedule: 12h)
|
||||
# This does NOT run a snapshot. It just saves the schedule.
|
||||
echo 'Setting 12-hour schedule for /source/installers...' && \
|
||||
kopia policy set /source/installers \
|
||||
--snapshot-interval 12h \
|
||||
--keep-daily 7 \
|
||||
--keep-weekly 4 \
|
||||
--keep-monthly 12 \
|
||||
--password=${KOPIA_REPOSITORY_PASSWORD} \
|
||||
&& \
|
||||
# 4. SET POLICY for immich-photos (Schedule: 12h)
|
||||
echo 'Setting 12-hour schedule for /source/immich-photos...' && \
|
||||
kopia policy set /source/immich-photos \
|
||||
--snapshot-interval 12h \
|
||||
--keep-daily 7 \
|
||||
--keep-weekly 4 \
|
||||
--keep-monthly 12 \
|
||||
--password=${KOPIA_REPOSITORY_PASSWORD}
|
||||
|
||||
echo 'Initialization complete. Repository created and policies set.'
|
||||
|
||||
# Do not restart since it's a one-off command
|
||||
restart: "no"
|
||||
|
||||
# Re-using the same Docker-managed volumes
|
||||
volumes:
|
||||
kopia_config:
|
||||
kopia_cache:
|
||||
kopia_logs:
|
||||
|
|
@ -24,14 +24,15 @@ services:
|
|||
- kopia_logs:/app/logs
|
||||
|
||||
# --- YOUR BACKUP DESTINATION ---
|
||||
# Maps your host's F:\test_backup to /app/repository inside the container.
|
||||
# Maps your host's G:\kopia-backups to /app/repository inside the container.
|
||||
# Kopia will write its backup data here.
|
||||
- f:/test_backup:/app/repository
|
||||
- g:/kopia-backups:/app/repository
|
||||
|
||||
# --- YOUR SOURCE DATA ---
|
||||
# Maps your host's E:\installers to /source/installers inside the container.
|
||||
# Maps your host's E:\installers and H:\immich-photos to /source/installers inside the container.
|
||||
# ':ro' (read-only) is a safety best practice.
|
||||
- e:/installers:/source/installers:ro
|
||||
- h:/immich-photos:/source/immich-photos:ro
|
||||
|
||||
command:
|
||||
- server
|
||||
|
|
@ -39,6 +40,7 @@ services:
|
|||
- --ui
|
||||
- --address=0.0.0.0:51515
|
||||
- --insecure
|
||||
- --password=${KOPIA_REPOSITORY_PASSWORD}
|
||||
- --server-username=${KOPIA_SERVER_USERNAME}
|
||||
- --server-password=${KOPIA_SERVER_PASSWORD}
|
||||
restart: unless-stopped
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue