Skip to content

Instantly share code, notes, and snippets.

@relekang
Last active September 30, 2020 23:49
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save relekang/7136687 to your computer and use it in GitHub Desktop.
Save relekang/7136687 to your computer and use it in GitHub Desktop.
Simple Redis dump and copy every other hour. Run puppet apply redis-backup.pp to install. The copying will overwrite the last backup from the same day.
file{ [ '/backups', '/backups/redis' ]:
ensure => 'directory',
owner => 'root'
}
cron{ 'redis-bgsave':
command => 'redis-cli bgsave',
user => 'root',
hour => '0-23/2',
minute => 3,
}
cron{ 'redis-move-backup':
command => 'mv /var/lib/redis/dump.rdb /backups/redis/`date +%Y-%m-%d`.rdb',
user => 'root',
hour => '0-23/2',
minute => 23,
require => [ File['/backups/redis'], Cron['redis-bgsave'] ]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment