To restore a Redis database backup, perform the following steps.
Step 1
Create a Redis backup using SimpleBackups.
Step 2a
Go to your backup page, then select the "Logs" tab. Afterwards, click the little "( i )" on the right next to the copy you want to download.

Step 2b
Under the backup restore section on the modal that just popped up, click on "Click to generate a signed download link" then copy the resulting link
Step 3
On your server, run the following command, and use the signed download link you obtained in the previous step (ensure you enclose it in double quotes as shown):
wget "PasteTheSignedDownloadLinkHereBetweenTheQuotes" -O - | gunzip -dc > "redis-backup.rdb"
Step 4
Check if AOF setting is enabled in Redis before you restore your backup:
redis-cli CONFIG GET appendonly
Sample output of the command:
1) "appendonly"
2) "yes"
If AOF is not enabled (you see "no"
in the command output), you can directly go to Step 5.
Otherwise, you need to disable AOF first:
redis-cli CONFIG SET appendonly no
Then:
redis-cli CONFIG REWRITE
Step 5
5a) Find the current Redis data directory on your system where it stores its database:
redis-cli CONFIG GET dir
Sample output of the command:
1) "dir"
2) "/var/lib/redis"
In our case, the directory is /var/lib/redis
- note this directory since we will move our restored backup there later.
5b) Find the current Redis database filename:
redis-cli CONFIG GET dbfilename
Sample output of the command:
1) "dbfilename"
2) "dump.rdb"
In our case, and usually, the database filename is dump.rdb
as shown above - note this filename since we will ensure our restored backup is named like that later.
5c) Shut down Redis (stop the Redis server)
sudo service redis stop
5d) Back up your current Redis database if needed (optional):
cp -rf /var/lib/redis/*.rdb ~/any-redis-backup-directory/
5e) Delete all .aof
and .rdb
files in the Redis data directory from (Step 5a)
rm /var/lib/redis/*.aof /var/lib/redis/*.rdb
Step 6
Now we will copy the RDB backup file obtained in (Step 3), and restore it into the Redis data directory from (Step 5a) and rename it to the same dbfilename from (Step 5b).
Example based on the values we used in this guide:
sudo cp redis-backup.rdb /var/lib/redis/dump.rdb
sudo chown redis:redis /var/lib/redis/dump.rdb
sudo chmod 660 /var/lib/redis/dump.rdb
Note: If your Redis uses another user on the system that it other than redis
, ensure you replace redis:redis
by <redis-user>:<redis-user>
Start Redis
sudo service redis start
Quick check on the databases and their sizes
redis-cli INFO keyspace
Optional:
If you disabled AOF in (Step 4) and you need to enable it again:
redis-cli CONFIG SET appendonly yes
redis-cli CONFIG REWRITE
If you need any help in any of these steps, let us know and we can help you with the restore.