### Bringing Up Docker Compose Stack Source: https://github.com/restic/rest-server/blob/master/examples/compose-with-grafana/README.md This snippet first builds the Docker images for services defined in the `docker-compose.yml` file and then starts all services in detached mode. This deploys the Rest Server, Prometheus, and Grafana components. ```Shell docker-compose build docker-compose up -d ``` -------------------------------- ### Building Rest Server Docker Image Source: https://github.com/restic/rest-server/blob/master/examples/compose-with-grafana/README.md This snippet navigates to the project root, builds the `rest-server` Docker image using a Makefile, and then returns to the previous directory. This step is a prerequisite for running the Docker Compose stack. ```Shell cd ../.. make docker_build cd - ``` -------------------------------- ### Starting Rest Server with Custom Path and No Authentication (Shell) Source: https://github.com/restic/rest-server/blob/master/README.md This command starts the `rest-server` instance, configuring it to persist backup data in a specified directory (`/user/home/backup`) instead of the default temporary location. It also disables user authentication, allowing unauthenticated access to the server. ```sh rest-server --path /user/home/backup --no-auth ``` -------------------------------- ### Initializing and Performing Restic Backup Source: https://github.com/restic/rest-server/blob/master/examples/compose-with-grafana/README.md These commands initialize a new Restic repository on the running Rest Server and then perform a backup of the current directory to that repository. Executing these commands generates data that Prometheus scrapes and Grafana displays. ```Shell restic -r rest:http://127.0.0.1:8010/demo1 -p ./demo-passwd init restic -r rest:http://127.0.0.1:8010/demo1 -p ./demo-passwd backup . ``` -------------------------------- ### Starting Rest Server with Docker (Shell) Source: https://github.com/restic/rest-server/blob/master/README.md These commands pull the latest `restic/rest-server` Docker image and then run a container. The server is exposed on port 8000, and a host volume (`/my/data`) is mounted to `/data` inside the container for persistent storage, with the container named `rest_server`. ```sh docker pull restic/rest-server:latest docker run -p 8000:8000 -v /my/data:/data --name rest_server restic/rest-server ``` -------------------------------- ### Checking Docker Compose Service Status Source: https://github.com/restic/rest-server/blob/master/examples/compose-with-grafana/README.md This command lists the running services managed by Docker Compose, allowing verification that all components of the stack (Rest Server, Prometheus, Grafana) are operational and healthy. ```Shell docker-compose ps ``` -------------------------------- ### Displaying Rest Server Help Information (Console) Source: https://github.com/restic/rest-server/blob/master/README.md This command displays the available flags and usage instructions for the `rest-server` application. It provides a comprehensive list of options to configure the server's behavior, including listening address, data directory, authentication, TLS, and various operational modes. ```console $ rest-server --help Run a REST server for use with restic Usage: rest-server [flags] Flags: --append-only enable append only mode --cpu-profile string write CPU profile to file --debug output debug messages --group-accessible-repos let filesystem group be able to access repo files -h, --help help for rest-server --htpasswd-file string location of .htpasswd file (default: "/.htpasswd)" --listen string listen address (default ":8000") --log filename write HTTP requests in the combined log format to the specified filename (use "-" for logging to stdout) --max-size int the maximum size of the repository in bytes --no-auth disable .htpasswd authentication --no-verify-upload do not verify the integrity of uploaded data. DO NOT enable unless the rest-server runs on a very low-power device --path string data directory (default "/tmp/restic") --private-repos users can only access their private repo --prometheus enable Prometheus metrics --prometheus-no-auth disable auth for Prometheus /metrics endpoint --proxy-auth-username string specifies the HTTP header containing the username for proxy-based authentication --tls turn on TLS support --tls-cert string TLS certificate path --tls-key string TLS key path --tls-min-ver string TLS min version, one of (1.2|1.3) (default "1.2") -v, --version version for rest-server ``` -------------------------------- ### Building a Custom Rest Server Docker Image (Shell) Source: https://github.com/restic/rest-server/blob/master/README.md These commands clone the `rest-server` repository, navigate into its directory, and then build a custom Docker image tagged `restic/rest-server:latest` from the provided `Dockerfile`. This allows for local modifications or custom configurations of the server image. ```sh git clone https://github.com/restic/rest-server.git cd rest-server docker build -t restic/rest-server:latest . ``` -------------------------------- ### Building Project with Goreleaser (Shell) Source: https://github.com/restic/rest-server/blob/master/Release.md This snippet uses `goreleaser` to build and release the project, specifying parallel execution for efficiency. It dynamically generates release notes by invoking `calens` with a GitHub-specific changelog template and the current version, integrating release notes directly into the build process. ```shell goreleaser \ release --parallelism 4 \ --release-notes <(calens --template changelog/CHANGELOG-GitHub.tmpl --version "${VERSION}") ``` -------------------------------- ### Creating a New .htpasswd File and Adding a User (Shell) Source: https://github.com/restic/rest-server/blob/master/README.md This command uses the `htpasswd` utility to create a new `.htpasswd` file and add a user with a bcrypt-encrypted password. The `-c` flag indicates file creation, and `-B` specifies bcrypt encryption, which is recommended for security. ```sh htpasswd -B -c .htpasswd username ``` -------------------------------- ### Setting Development Version and Committing (Shell) Source: https://github.com/restic/rest-server/blob/master/Release.md This snippet updates the `main.go` file to append `-dev` to the version string, signifying a development build. This change is then committed to Git, preparing the repository for ongoing development work after a stable release has been cut. ```shell sed -i "s/var version = \"[^\"]*\"/var version = \"${VERSION}-dev\"/" cmd/rest-server/main.go git commit -m "Update version for development" cmd/rest-server/main.go ``` -------------------------------- ### Tagging and Pushing New Version (Shell) Source: https://github.com/restic/rest-server/blob/master/Release.md This snippet creates a signed, annotated Git tag for the new version, using the `VERSION` variable for the tag name and message. After the tag is created locally, it pushes all local tags to the remote repository, making the new version officially marked. ```shell git tag -a -s -m "v${VERSION}" "v${VERSION}" git push --tags ``` -------------------------------- ### Adding a User to Rest Server in Docker Container (Shell) Source: https://github.com/restic/rest-server/blob/master/README.md This command executes `create_user` inside the running `rest_server` Docker container to add a new user named `myuser`. The user will be prompted to set a password interactively, which is then stored in the container's `.htpasswd` file. ```sh docker exec -it rest_server create_user myuser ``` -------------------------------- ### Listening on Unix Socket and Remote Backup with rest-server and SSH Source: https://github.com/restic/rest-server/blob/master/CHANGELOG.md This snippet demonstrates how to configure `rest-server` to listen on a Unix socket and then use SSH remote port forwarding to enable a remote `restic` client to back up to this local `rest-server` instance. It shows the `rest-server` command for socket listening and the `ssh` command for forwarding and `restic` backup. ```Shell rest-server --listen unix:/tmp/foo & ssh -R /tmp/foo:/tmp/foo user@host restic -r rest:http+unix:///tmp/foo:/repo backup ``` -------------------------------- ### Managing Changelog Files (Shell) Source: https://github.com/restic/rest-server/blob/master/Release.md This snippet renames the `unreleased` changelog directory to a version-specific and date-stamped directory. It then cleans up any `.gitkeep` files, re-initializes the `unreleased` directory, and commits all changelog-related changes to Git, organizing the release notes. ```shell mv changelog/unreleased "changelog/${VERSION}_$(date +%Y-%m-%d)" rm -f "changelog/${VERSION}_$(date +%Y-%m-%d)/.gitkeep" git add "changelog/${VERSION}"* git rm -r changelog/unreleased mkdir changelog/unreleased touch changelog/unreleased/.gitkeep git add changelog/unreleased/.gitkeep git commit -m "Move changelog files for ${VERSION}" changelog/{unreleased,"${VERSION}"}* ``` -------------------------------- ### Generating and Committing CHANGELOG.md (Shell) Source: https://github.com/restic/rest-server/blob/master/Release.md This snippet uses the `calens` tool to generate the main `CHANGELOG.md` file, consolidating all release notes. The newly generated file is then added to Git and committed, ensuring the comprehensive changelog is part of the release. ```shell calens > CHANGELOG.md git add CHANGELOG.md git commit -m "Generate CHANGELOG.md for ${VERSION}" CHANGELOG.md ``` -------------------------------- ### Updating Version Files and Committing (Shell) Source: https://github.com/restic/rest-server/blob/master/Release.md This snippet updates the `VERSION` file and modifies the `main.go` source file to embed the new version number. After these files are updated, the changes are committed to Git, formally recording the version update in the repository history. ```shell echo "${VERSION}" | tee VERSION sed -i "s/var version = \"[^\"]*\"/var version = \"${VERSION}\"/" cmd/rest-server/main.go git commit -m "Update VERSION files for ${VERSION}" VERSION cmd/rest-server/main.go ``` -------------------------------- ### Exporting Version Variable (Shell) Source: https://github.com/restic/rest-server/blob/master/Release.md This snippet exports the `VERSION` environment variable, setting it to a specific version number. This variable is crucial as it's referenced in all subsequent steps to ensure consistent versioning throughout the release process. ```shell export VERSION=0.10.0 ``` -------------------------------- ### Adding a User with Password to Rest Server in Docker Container (Shell) Source: https://github.com/restic/rest-server/blob/master/README.md This command executes `create_user` inside the running `rest_server` Docker container to add a new user named `myuser` with a specified password `mypassword`. This method allows for non-interactive user creation with a pre-defined password. ```sh docker exec -it rest_server create_user myuser mypassword ``` -------------------------------- ### Generating Self-Signed TLS Certificate and Key (Shell) Source: https://github.com/restic/rest-server/blob/master/README.md This `openssl` command generates a self-signed RSA 2048-bit TLS certificate and a corresponding private key. It creates `private_key` and `public_key` files, valid for 365 days, and includes Subject Alternative Names for both IP address and domain, useful for testing TLS without a CA. ```sh openssl req -newkey rsa:2048 -nodes -x509 -keyout private_key -out public_key -days 365 -addext "subjectAltName = IP:127.0.0.1,DNS:yourdomain.com" ``` -------------------------------- ### Deleting a User from Rest Server in Docker Container (Shell) Source: https://github.com/restic/rest-server/blob/master/README.md This command executes `delete_user` inside the running `rest_server` Docker container to remove an existing user named `myuser`. This action removes the user's entry from the `.htpasswd` file, revoking their access to the server. ```sh docker exec -it rest_server delete_user myuser ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.