Skip to content
iman daneshi edited this page Feb 19, 2016 · 5 revisions

"Redis is an open source (BSD licensed), in-memory data structure store, used as database, cache and message broker."

We use redis for group bans,global bans,chat stats and ...

Issues

Can't Connect With Redis install/configure it!

You just need to start the redis server

sudo service redis-server start

Backup

1- Save your DB

redis-cli save

2- Backup it

sudo cp /var/lib/redis/dump.rdb /backup/location/you/want/to/save/your/database

For example

sudo cp /var/lib/redis/dump.rdb /home/teleseed

Restore

In case it is not AOF mode. ('no') the process is quite straight forward. First, just stop redis server

/etc/init.d/redis-server stop

Then, remove the current dumb.rdb file

rm -f /var/lib/redis/dump.rdb

And now the snapshot file has gone, therefore we definitely want the backup one back in.

cp /backup/dump.rdb

Remember to set it to be owned by redis user/group

chown redis:redis dump.rdb

Now, just start the Redis server.

/etc/init.d/redis-server start

Done.


In case it is AOF mode. ('yes'),* it involes a bit more process. The first thing to do is the same as previos case, just stop the redis server

/etc/init.d/redis-server stop

Go inside directory where dump.rdb is located

cd /var/lib/redis/

After that, clean dump.rb and appendonly.aof files up

rm -f dump.rdb appendonly.aof

Copy the backup file in the place, along the line, correct its permission.

chown redis:redis /var/lib/redis/dump.rdb```

The important part is to disable AOF by editing /etc/redis/redis.conf file, set appendonly as no

```appendonly no```

Run the following command to create new appendonly.aof file

Next, start the Redis server and issue the BGREWRITEAOF command:

```/etc/init.d/redis-server start
redis-cli BGREWRITEAOF```

Check the progress (0 - done, 1 - not yet)

```redis-cli info | grep aof_rewrite_in_progress```

You should see a new appendonly.aof file. Next, stop the server.

```/etc/init.d/redis-server stop```

After it finished, enable AOF again by changing appendonly in /etc/redis/redis.conf file to yes

```appendonly yes```

Then start the redis server again.

```/etc/init.d/redis-server start```

And we are done.

# Security

[How To Secure Your Redis Installation](https://www.digitalocean.com/community/tutorials/how-to-secure-your-redis-installation-on-ubuntu-14-04)
Clone this wiki locally