Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🖥️ Homelab

This repository contains a simple homelab setup based on Docker Compose.

Services are split into multiple compose files under the services directory and managed through a custom compose script.
The setup also includes a Restic-based backup system to handle periodic backups.

🚀 Requirements

  1. Install Docker to run the services
  2. Install Restic to create and handle backups

⚡️ Docker

The compose script will run services in the docker-compose.yml file and all the ones in the .yml files under the services directory.
To create a new container add it to an existing file or create a new .yml file.

🛠️ Commands

Here is the list of the commands for the compose script:

# Starts all containers and detach
sh compose detach

# Starts all containers
sh compose up

# Stops all servies and removes orphans
sh compose down

# Updates all container images
sh compose pull

🔁 Autorun & service

The compose script can be run as a systemd service creating a dedicated file in /etc/systemd/system/.
The contents of the homelab.service should be similar to:

[Unit]
Description=Start homelab containers
After=docker.service network-online.target
Wants=docker.service

[Service]
Type=oneshot
WorkingDirectory=/path/to/homelab
ExecStart=/path/to/homelab/compose detach
RemainAfterExit=yes
# RequiresMountsFor=/mnt/drive # Include the mount point if needed

[Install]
WantedBy=multi-user.target

💾 Restic

The backup script will create a new backup and save all informations in a .log file.

Before running the script a new repository needs to be initialized with restic init --repo /path/to/backups.
The password needs to be set in the .env file to be able to create new backups.

🔁 Autorun & service

For a better backing up system the script can be run as a systemd service creating a dedicated restic.service and restic.timer.
The contents of restic.service and restic.timer should be similar to:

[Unit]
Description=Restic homelab backup
Wants=network-online.target
After=network-online.target docker.service

[Service]
Type=oneshot
WorkingDirectory=/path/to/homelab
ExecStart=/path/to/homelab/backup
StandardOutput=journal
StandardError=journal
# RequiresMountsFor=/mnt/drive # Include the mount point if needed

[Install]
WantedBy=multi-user.target
[Unit]
Description=Restic homelab daily backup

[Timer]
OnCalendar=*-*-* 03:00:00
Persistent=true

[Install]
WantedBy=timers.target

🔐 Environment variables

The .env.sample file must be copied to .env.
This file is used by Docker services and containers.

The .env.bk.sample file must be copied to .env.bk.
This file is used by the backup scripts.

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages