Skip to content

Is is possible to purge automation logs after N days? #11156

Answered by melohagan
hawkinsjon asked this question in Help
Discussion options

You must be logged in to vote

This script that @shogunpurple wrote may also help you out in the meantime!

#!/bin/bash

# URL of your CouchDB instance
couchdb_url="http://localhost:5984"

# Name of your database
database="prod_app_db"

# Get the timestamp for one week ago
timestamp_one_week_ago=$(date -v-1w -u +'%Y-%m-%dT%H:%M:%SZ')

# Query to match the documents
query='{
  "selector": {
    "_id": {
      "$regex": "^log_au"
    },
    "createdAt": {
      "$lt": "'"$timestamp_one_week_ago"'"
    }
  }
}'

# Get the documents matching the query
docs=$(curl -s -X POST "$couchdb_url/$database/_find" -H "Content-Type: application/json" -d "$query")

# Extract document IDs and revision IDs
ids_and_revs=$(echo "$docs" | j…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@melohagan
Comment options

Answer selected by hawkinsjon
@hawkinsjon
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
bb-automations Budibase Automations related work
2 participants