Help running rest commands

Hi,

I have set up a remote REST server instance to work with RESTIC.
However, after the server is configured, I try to access it with this command and I get an error :

 [root@centos-7 ~]# restic -r rest:http://amanda-server:8000

restic is a backup program which allows saving multiple revisions of files and
directories in an encrypted repository stored on different backends.

Usage:
  restic [command]

Available Commands:
  backup        Create a new backup of files and/or directories
  cache         Operate on local cache directories
  cat           Print internal objects to stdout
  check         Check the repository for errors
  diff          Show differences between two snapshots
  dump          Print a backed-up file to stdout
  find          Find a file, a directory or restic IDs
  forget        Remove snapshots from the repository
  generate      Generate manual pages and auto-completion files (bash, zsh)
  help          Help about any command
  init          Initialize a new repository
  key           Manage keys (passwords)
  list          List objects in the repository
  ls            List files in a snapshot
  migrate       Apply migrations
  mount         Mount the repository
  prune         Remove unneeded data from the repository
  rebuild-index Build a new index file
  recover       Recover data from the repository
  restore       Extract the data from a snapshot
  self-update   Update the restic binary
  snapshots     List all snapshots
  stats         Scan the repository and show basic statistics
  tag           Modify tags on snapshots
  unlock        Remove locks other processes created
  version       Print version information

Flags:
      --cacert file               file to load root certificates from (default: use system certificates)
      --cache-dir string          set the cache directory. (default: use system default cache directory)
      --cleanup-cache             auto remove old cache directories
  -h, --help                      help for restic
      --json                      set output mode to JSON for commands that support it
      --key-hint string           key ID of key to try decrypting first (default: $RESTIC_KEY_HINT)
      --limit-download int        limits downloads to a maximum rate in KiB/s. (default: unlimited)
      --limit-upload int          limits uploads to a maximum rate in KiB/s. (default: unlimited)
      --no-cache                  do not use a local cache
      --no-lock                   do not lock the repo, this allows some operations on read-only repos
  -o, --option key=value          set extended option (key=value, can be specified multiple times)
      --password-command string   specify a shell command to obtain a password (default: $RESTIC_PASSWORD_COMMAND)
  -p, --password-file string      read the repository password from a file (default: $RESTIC_PASSWORD_FILE)
  -q, --quiet                     do not output comprehensive progress report
  -r, --repo string               repository to backup to or restore from (default: $RESTIC_REPOSITORY)
      --tls-client-cert string    path to a file containing PEM encoded TLS client certificate and private key
  -v, --verbose n                 be verbose (specify --verbose multiple times or level n)

Use "restic [command] --help" for more information about a command.
[root@centos-7 ~]#

How do I resolve this, and make restic work, i.e. access the remote server via REST?

This isn’t all of your command, is it? Because if so, then you are missing commands.
Right now you have only added command line flags and not actual commands restic should run.

To expand on what @moritzdietz said, you’ve told restic where the repository is, but you haven’t told restic what you want to do with the repository. You need to add a command like init, snapshots, backup, etc.

Thanks, I figured that I have to execute commands to initialize the repo first like this :

restic -r rest:http://test:test@[server]:8000/testrepo2 init

However the default directory for backup data in the restic server is /tmp/restic. I created a different directory, which is /testback1. However when I run the command below to start a custom directory with authentication disabled, it hangs for a very long time at this :

[root@amanda-server rest-server]# rest-server --path /testback1 --no-auth
Data directory: /testback1
Authentication disabled
Private repositories disabled
Starting server on :8000

Thus I press Control-C to escape, and run the command without the no-auth option :

[root@amanda-server rest-server]# rest-server --path /testback1
Data directory: /testback1
Authentication enabled
error: cannot load .htpasswd (use --no-auth to disable): stat /testback1/.htpasswd: no such file or directory

And do I have to run the custom command above before I initialize the repo?

It’s supposed to. Note “Starting server on :8000” – that means the server is running, and you can now connect to it on port 8000.

So this means I have to leave it in this state forever while I am using the repo?
Feels awkward to just leave it hanging like that? Why would it not just start like a normal service?

Also for this command to initialize the repo remotely :

restic -r rest:http://test:test@[server]:8000/testrepo2 init

What does the ‘test:test’ from the command above represent?

Define “normal service” for me.

Yes, the server must continuously run if you want to use it. If you like you could run it through systemd. I use the following unit file in /etc/systemd/system/restic-server.service:

[Unit]
Description=Restic Rest Server
After=syslog.target
After=network.target

[Service]
Type=simple
User=restic
Group=restic
ExecStart=/usr/local/sbin/rest-server --append-only --listen 127.0.0.1:8005 --path /var/restic --private-repos
Restart=always
RestartSec=5
StartLimitInterval=0

[Install]
WantedBy=multi-user.target

You can adapt this to your needs. Note in particular that I created a local restic service user and group, and that I have the binary installed at /usr/local/sbin/rest-server.

Once the file is in place, systemctl enable restic-server && systemctl start restic-server.

Thanks for the reply. Today I tried to initialize, and run the backup, and seems like it is successful :

Initialize :

[root@centos-7 ~]# restic -r rest:http://resticuser:1qazxsw2@amanda-server:8000/testback1 init
enter password for new repository:
enter password again:
created restic repository 1746bdcd32 at rest:http://resticuser:1qazxsw2@amanda-server:8000/testback1

Please note that knowledge of your password is required to access
the repository. Losing your password means that your data is
irrecoverably lost.
[root@centos-7 ~]#

Backup :

[root@centos-7 ~]# restic backup -r rest:http://resticuser:1qazxsw2@amanda-server:8000/testback1 .
enter password for repository:
repository 1746bdcd opened successfully, password is correct
created new cache in /root/.cache/restic

Files:          14 new,     0 changed,     0 unmodified
Dirs:            0 new,     0 changed,     0 unmodified
Added to the repo: 8.620 KiB

processed 14 files, 2.697 KiB in 0:00
snapshot 5a6647f5 saved
[root@centos-7 ~]#

However, I am not sure of the command to use to list the snapshot in the remote server from this current server. I tried running the command in the remote server directly (amanda-server) :

[root@amanda-server ~]# restic -r /testback1 snapshots
Fatal: unable to open config file: Stat: stat /testback1/config: no such file or directory.                                                                               
Is there a repository at the following location?
/testback1
[root@amanda-server ~]# 

Is it wrong to do it directly in the remote server?

No, you can run it on the server. What are the contents of /testback1?