Open rahman77889 opened 1 month ago
Here's how to back up all comments, remove those older than one month using a shell script with jq
, and restore the modified backup:
First, back up the comments using the provided docker exec
command:
docker exec -it remark42 backup -s {your site ID}
This will create a file named userbackup-{site ID}-{timestamp}.gz
.
Next, extract the backup file to work with it:
gzip -d userbackup-{site ID}-{timestamp}.gz
Create a shell script to filter out comments older than one month using jq
:
#!/bin/bash
input_file="userbackup-{site ID}-{timestamp}"
output_file="filtered_userbackup-{site ID}-{timestamp}"
one_month_ago=$(date -d '1 month ago' +%s)
jq --argjson one_month_ago "$one_month_ago" '
select(.time | fromdateiso8601 | mktime > $one_month_ago)
' "$input_file" > "$output_file"
Replace {site ID}
and {timestamp}
with the actual values.
Save this script as filter_comments.sh
and make it executable:
chmod +x filter_comments.sh
Run the script:
./filter_comments.sh
Compress the filtered backup file:
gzip filtered_userbackup-{site ID}-{timestamp}
Finally, restore the comments using the provided docker exec
command:
docker exec -it remark42 restore -f filtered_userbackup-{site ID}-{timestamp}.gz -s {your site ID}
By following these steps, you'll be able to back up all comments, filter out those older than one month using a shell script with jq
, and restore the modified backup effectively removing the old comments.
Hello
As you know, not every single needs to store all comments for months or even more
With minimum resources, we need a new feature that can auto-remove and only keep the latest 1-month
It will be better for maintaining performance and high availability with minimum treatment
Thank you very much