Restic + Rclone + gdrive

Hello everyone, everything good.
I am using rclone + gdrive.
I wanted to use restic + rclone + gdrive.
Not understanding the logic for using restic + rclone in the restic and rclone Doc are different examples.
I need the backup older than 30 days to be deleted from google drive.

can you help me?

Hey @juanmaia and welcome to the restic community :slight_smile:

From the restic documentation on Removing snapshots according to a policy:

--keep-within duration keep all snapshots which have been made within the duration of the latest snapshot. duration needs to be a number of years, months, days, and hours, e.g. 2y5m7d3h will keep all snapshots made in the two years, five months, seven days, and three hours before the latest snapshot.

So you can simply keep doing your backups as you would and then once in a while you can run:
restic forget --keep-within 30d and this makes sure that all your snapshots that you have taken, no matter when or how many days you didn’t do any backups, it is always 30 days from now backwards.

Another explanation is:
So if you give a duration of 12m, and your last snapshot was made 1m ago, it will keep all snapshots within 13 months of now. The reason it’s since the latest snapshot is to ensure you have a window of snapshots for that long which you can restore, rather than deleting snapshots over time just because time is passing.

I hope this helps you. If it does, please let us know :slight_smile:

1 Like

I installed restic and restarted the repository.
export RESTIC_PASSWORD = “mypassword”
restic -r rclone: gdrive: test init
all ok so far!
I performed the first backup:
restic -r rclone: gdrive: test backup.tar.gz (6GB)

repository d63dbc4f opened successfully, password is correct

Files: 1 new, 0 changed, 0 unmodified
Dirs: 1 new, 0 changed, 0 unmodified
Added: 3,465 GiB

processed 1 files, 5,236 GiB in 24:00

when I run the command:
rclone ls gdrive: test
the response and hundreds of files.
I see the same through the google drive panel.
I don’t see the backup.tar.gz file
what does that mean?

It means that you’re looking at the raw repository files, which aren’t meant to be directly used.

Instead, run restic -r ... snapshots to see a list of snapshots. If you want to look at the contents of a snapshot, run restic -r ... ls $snapshot_id.

1 Like

Thank you for your help @moritzdietz :raised_hands::v:

thanks for answering @cdhowie
To understand and I’m already taking good steps now. :slight_smile:
I have some VPS server, each vps will have its repository in the same directory as google drive: / BACKUPS
I plan to have on my google drive the following tree:
/ BACKUPS / {SERVER01, SERVER02, SERVER03 … and MIGRATION}
Ex: server01, will have access to the directory SERVER01 AND MIGRATION.
all servers had access to the MIGRATION directory.
my doubts are as follows:
1-How can I access the directory without having to enter the password every time?
2- it is possible to configure access of all VPS to a single directory (MIGRATION)

You can set the RESTIC_PASSWORD environment variable to convey the password to restic.

I use the following wrapper script and I create one per repository. For example, if saved at /usr/local/bin/restic-repo1 then you can run restic-repo1 snapshots to see snapshots without entering any password or repository location.

#!/bin/sh

export RESTIC_REPOSITORY=/path/to/repository
export RESTIC_PASSWORD='yourpassword'

exec restic "$@"

Note that you should set the permissions on the script appropriately so that unprivileged users can’t cat the script to see the password.

Sure, you just have to set the directory ownership and permissions appropriately. This is more of a Unix permissions question than a restic question.

So if you only want to have the file backup.tar.gz on Google Drive you can safely just use rclone. But then you don’t have to use restic for this.
I think many answers you might have will be answered if you take a look at the documentation of restic.
Primarily I think you should give this a read: https://restic.readthedocs.io/en/latest/100_references.html#design

You don’t have to understand all the technical terms but you should get an idea of how restic works in general.

As you posted earlier you have already seen the environment variable for both the repository and the passphrase for the repository.
As @cdhowie already said, you can create a .sh script with that information already in it, or if you can edit the .bashrc or .bash_profile file on your VPS to include the exports for the repository - you will be able to google that if you have problems along the way.
Then when you SSH into your VPS, the shell is already setup and you can just type restic snapshots and will see all snapshots of your VPS.

On this I am not quiet sure as @cdhowie is. Could you maybe rephrase that question so I can understand it better? What are you trying to solve? Thanks :slight_smile: