What's amazing is that happening to several people in the same days interval on different redis version and nodeBB version without touching anything from days !!!
I've backup up also every hour now !!!
crontab - e
then add
# 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/
#
# For more information see the manual pages of crontab(5) and cron(8)
#
# m h dom mon dow command
MAILTO=""
13 * * * * /root/redis-backup.sh
And /root/redis-backup.sh
(grabbed from Internet, don't remember where and modified to fit my needs).
dont forget to chmod ug+x /root/redis-backup.sh
#!/bin/bash
#
## redis backup script
## usage
## redis-backup.sh port backup.dir
port=${1:-6379}
backup_dir=${2:-"/var/lib/redis/backup"}
cli="/usr/bin/redis-cli -p $port"
rdb="/var/lib/redis/dump.rdb"
test -f $rdb || {
echo "[$port] No RDB Found" ; exit 1
}
test -d $backup_dir || {
echo "[$port] Create backup directory $backup_dir" && mkdir -p $backup_dir
}
# perform a bgsave before copy
echo bgsave | $cli
echo "[$port] waiting for 5 seconds..."
sleep 5
try=10
while [ $try -gt 0 ] ; do
## redis-cli output dos format line feed '\r\n', remove '\r'
bg=$(echo 'info Persistence' | $cli | awk -F: '/rdb_bgsave_in_progress/{sub(/\r/, "", $0); print $2}')
ok=$(echo 'info Persistence' | $cli | awk -F: '/rdb_last_bgsave_status/{sub(/\r/, "", $0); print $2}')
if [ "$bg" = "0" ] && [ "$ok" = "ok" ] ; then
dst="$backup_dir/$port-dump.$(date +%Y%m%d%H%M).rdb"
cp $rdb $dst
if [ $? = 0 ] ; then
echo "[$port] redis rdb $rdb copied to $dst."
# delete rdb created 30 days ago
cd $backup_dir
find . \( -name "$port-dump*" \) -mtime +30 -exec rm -f {} \;
exit 0
else
echo "[$port] >> Failed to copy $rdb to $dst!"
fi
fi
try=$((try - 1))
echo "[$port] redis maybe busy, waiting and retry in 5s..."
sleep 5
done
If it can help, it can be better and not in root folder, done in a hurry, you know what I mean