Back Up Linux VPS to OneDrive via Restic and Rclone

There are a lot of ways to back up Linux, but it might not immediately be clear how you would go about backing up your VPS (Virtual Private Server) when you have no place to store your backups. This will be from a personal point of view, not enterprise, but the tools I’m using for this ARE.

I have a VPS that I use for IT labs, learning, and fun. Because it’s for personal use, I do not have any hardware (or fancy paid backup software) to use as a backup repository. However, I do subscribe to O365 Home, and along with that comes 1TB of OneDrive storage per user. My VPS is small, so I don’t mind it taking up a few gigs on my OneDrive storage allowance.

Restic is a free and open source backup program that truly does backups right, and Rclone is a command line program that synchronizes files to and from just about every major cloud storage service you can find.

Office 365 Home Setup

I didn’t want to risk having my personal OneDrive account exposed to my VPS, so I decided to use a separate account for this purpose. This will give me about 1 TB of space for my backups, which is plenty for this case. I only need a few GBs.

  1. Add a new family member here:
    2. I created a new account for this.

Rclone Setup

I need to use Rclone on a headless server, so in order to set up Rclone on this headless server, I also needed to download and extract Rclone.exe on a computer that has an OAuth capable web browser. In my case, I used my Windows desktop, so instructions will be for that.

  1. Install Rclone on your Linux server:
    1. My VPS uses Fedora, so I entered the following command:
      dnf install rclone -y
  2. Configure Rclone:
    rclone config

    1. Follow the prompts shown in the “Rclone OneDrive Setup” reference at the bottom of this page.
    2. When you get to the following area pictured below, select NO, then refer to the “Rclone Remote (headless) Setup” reference:

    3. On your desktop with an OAuth-capable browser, open a CLI window, then enter the following command:
      rclone.exe authorize "onedrive"
    4. After you are finished on the Windows desktop, copy the code it gives to your Linux server when specified.
    5. Finish out the config wizard.
  3. Test the Rclone connection on your Linux server using the following command:
    rclone lsd remote:

    1. It should list your top level directories on OneDrive.

Restic Setup

This is the backup software that does the magic.

  1. Install Restic:
    dnf install restic -y
  2. Initiate a new Restic backup repository to your Rclone location:
    restic -r rclone:remote:TGServBackup init

    1. …where “remote” is the name of the Rclone remote, and TGServBackup is the name of the OneDrive folder I want to use.

Backing Up

  1. Back up a folder:
    restic -r rclone:remote:TGServBackup backup --verbose /home


  1. To restore, enter the following similar command:
    restic -r rclone:remote:TGServBackup restore 67bde04d --target /tmp/restore

Navigating Repos

  1. List available snapshots in your Rclone repo:
    restic -r rclone:remote:TGServBackup snapshots

Removing Stale Snapshots

You can set up policy to automatically remove old snapshots and to set the retention policy. There’s not a whole lot of sense duplicating the instructions, as they are so basic, so here’s the direct link:

Useful Commands

  • To copy a file or folder to your Rclone OneDrive remote:
    rclone copy /home/user/directory remote:FolderName
    rclone copy /home/user/file remote:FolderName


Preparing a new Restic repo – Other Services via rclone:

Rclone OneDrive setup:

Rclone Remote (headless) setup:

Restic Backing up Reference:




One Comment

  1. How can I achieve this automatically. As restic asks for a password each time I want to do a backup manually.

Leave a Reply

Your email address will not be published. Required fields are marked *