Skip to content

Archive your Reddit profile's Comments and Saved, Upvoted, and Downvoted Posts locally.

License

Notifications You must be signed in to change notification settings

javenlalla/my-reddit-archiver

Repository files navigation

My Reddit Archiver

Self-hosted web application to archive your Reddit profile's Comments and Saved, Upvoted, and Downvoted Posts locally.

Note: This project is currently under active development. There will be data structure and/or bc-breaking changes until the first official release is pushed.

Features

  • Create a local Archive of your Reddit profile content
  • Pull down Comments and Saved/Upvoted/Downvoted Posts to your Archive
  • Search your Archive
  • Filter by Subreddit
  • Filter by Flair Texts of Posts
  • Create custom Tags for Posts
    • Filter by Tags
  • Track API calls and usage to Reddit's API

Prerequisites

Create Reddit Client ID And Secret

In order to configure the application, a Reddit Client ID and Client Secret must be generated. This is accomplished by creating a Reddit app under your account. The app and its credentials are needed to make authorized APIs calls to the Reddit API to retrieve user account data such as the profile's Saved Link Posts and Comments.

  1. While logged into Reddit, navigate to Authorized Applications.
  2. Scroll to the bottom of the page and click create another app.
  3. Provide the following information:
    • Name: a name for client app
    • Select script
    • Redirect URI: though not used at this time for this project's current implementation, this is needed to create the client app. The server url where the project will be served can be used here.
  4. Click create app.
  5. Note down the Client ID and Client Secret as shown in the following screenshot:
    • Client ID And Secret

Limitations

2FA

The application requires your Reddit Password to be provided in the configuration. This is used to make authenticated OAuth calls in order to use Reddit's API. As a result, this flow does not work if 2FA is enabled on the target Reddit account. This may be addressed in the future with a redirect to Reddit for login, but at this time, the only workaround is to disable 2FA.

Setup

The application can be configured to run via docker-compose or docker run. See the following sections on how to spin up the application with either of these methods.

Environment Variables

The first step is to set the Environment Variables required by the application. See the table below for an overview of the required variables.

Environment Variable Default Description
REDDIT_USERNAME Your Reddit username.
REDDIT_PASSWORD Your Reddit password.
REDDIT_CLIENT_ID The Client ID of the Reddit App you created.
REDDIT_CLIENT_SECRET The Client Secret of the Reddit App you created.

For convenience, an .env.sample file is provided in the root of this repository. Copy that file to .env and update the placeholder values to real values.

docker run

If the docker run method is preferred for running the application, proceed with this section. If the docker-compose method is preferred, skip to [docker-compose(#docker-compose)].

Run the appropriate command below based on if using a .env file or inline Environment Variables.

Note: The volume mounts are needed for backup/persistent storage of the archive database and downloaded media assets from Reddit Posts.

With .env file:

docker run -d \
  --env-file=.env \
  --volume </path/to/media>:/r-media \
  --volume </path/to/database-folder>:/database \
  -p HOST_PORT:80 \
  --name mra \
  javenlalla/mra

Inline Environment variables:

docker run -d \
  -e REDDIT_USERNAME='MyRedditUsername' \
  -e REDDIT_PASSWORD='MyRedditPassword' \
  -e REDDIT_CLIENT_ID='MyAppClientID' \
  -e REDDIT_CLIENT_SECRET='MyAppClientSecret' \
  --volume </path/to/media>:/r-media \
  --volume </path/to/database-folder>:/database \
  -p HOST_PORT:80 \
  --name mra \
  javenlalla/mra

docker-compose

If the docker-compose method is preferred for running the application, proceed with the following steps.

  1. Create a docker-compose.yml:

    services:
      mra:
        container_name: mra
        image: javenlalla/mra
        volumes:
          - </path/to/media-folder>:/r-media
          - </path/to/database-folder>:/database
        environment:
          REDDIT_USERNAME: MyRedditUsername
          REDDIT_PASSWORD: "MyRedditPassword"
          REDDIT_CLIENT_ID: "MyAppClientID"
          REDDIT_CLIENT_SECRET: "MyAppClientSecret"
        ports:
          - "3580:80"
  2. Adjust the volumes paths, environment variables, and port as needed.

  3. Start application.

    docker-compose up -d

SSL

Because the application server runs on port 80 within its container, it is highly recommended to put MRA behind a secured reverse proxy such as Nginx Proxy Manager or Traefik.

Syncing

Syncing is executed automatically in the following cases:

  1. On container start/spin-up
  2. Twice an hour at :00 and :30

Logging

Container Logs

View the container logs using the following Docker command:

docker logs mra

Updating

Update | docker run

  1. Stop current container.

    docker stop mra
  2. Pull latest image.

    docker pull javenlalla/mra
  3. Start application as previously set up with this method. See docker run for more information.

Update | docker-compose

  1. Stop current container.

    docker stop mra
  2. Pull latest image.

    docker pull javenlalla/mra
  3. Remove the current container and start it again with the latest image.

    docker-compose up -d --force-recreate --build

Development

For developing in this application, see Development.

About

Archive your Reddit profile's Comments and Saved, Upvoted, and Downvoted Posts locally.

Resources

License

Stars

Watchers

Forks