Skip to content
GitLab
Projects Groups Topics Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
  • D doc-website
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributor statistics
    • Graph
    • Compare revisions
  • Issues 0
    • Issues 0
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 0
    • Merge requests 0
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Artifacts
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Model experiments
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Systerserver
  • doc-website
  • Wiki
  • Container Backups with Restic

Container Backups with Restic · Changes

Page history
Backup user with restricted sudo privileges authored May 23, 2021 by Mara Karagianni's avatar Mara Karagianni
Hide whitespace changes
Inline Side-by-side
Container-Backups-with-Restic.md
View page @ 420cbe3b
......@@ -28,21 +28,44 @@ Note: all system paths and parameters in this HOWTO are fictional.
To securely copy the public key, we shall enable password authentication at remote's server file */etc/ssh/sshd_config*, and disable it after having copied the public key.
`$ ssh-copy-id -i ~/.ssh/other_key.pub user@remote-host`
https://www.simplified.guide/ssh/copy-public-key
**2. How to run the backup command without root privilege**
**2. How to run the backup command without root privilege?**
The idea is to execute the restic binary with a backup user, aka execute a binary meant for root without being root.
As root we add a new user
`# useradd backupuser`
*creates the new user and a group with the same name*
`# chown root:backupuser /usr/bin/restic`
*makes user root and group backupuser owners of the restic binary*
`# chmod 750 /usr/bin/restic`
*user root has now read, write, execute permissions, and users in backupuser group can execute and read the restic binary*
`# setcap cap_dac_read_search=+ep ~backupuser/bin/restic`
*assigns capabilities to backup the whole system*
Ref: https://restic.readthedocs.io/en/stable/080_examples.html#backing-up-your-system-without-running-restic-as-root
\ No newline at end of file
*extends the capabilities of backupuser to backup the whole system*
Ref: https://restic.readthedocs.io/en/stable/080_examples.html#backing-up-your-system-without-running-restic-as-root
**3. How to run specific root commands by a non root user?**
*Note: we need that for stopping, checking status and starting of the lxc containers.
Best practice is to run our LXC containers rootless. This requires a different configuration of the containers' network setup, see details at
https://www.cyberciti.biz/faq/how-to-create-unprivileged-linux-containers-on-ubuntu-linux/*
Here we will give the backupuser restricted root privilege for the specific lxc commands we need to run during the backup process.
Give the backup user the access for specific commands to be executed as 'root'.
Add these commands in a new file under /etc/sudoers.d/
`vi /etc/sudoers.d/00-backupuser`
`bintibackup ALL=(ALL) NOPASSWD: /usr/bin/lxc-stop, /usr/bin/lxc-start, /usr/bin/lxc-info, /usr/bin/lxc-ls`
*https://www.cyberciti.biz/faq/linux-unix-running-sudo-command-without-a-password/*
Clone repository
  • Container Backups with Restic
  • Mailing Lists Docs
  • Sysadmin tasks
  • Home