Thursday, November 12, 2015

Backing up Data

Backing up data is always a good idea, especially if it is something you will want later.
If it is a personal file Google Drive, Drop Box and One Box are all great resources that give you between 5 and 30 gig of space for free.

There are various methods of backing up data. If you are just backing up files the above will do. If you want more advanced options or more space you can always set up an sftp server and rsync your files. Whatever it is you are backing up make sure you back it up properly.

One thing I do want to mention is backup rotation. There are various methods of backing up data and one is simply to overwrite the old backup with a new one. This is nice if you loose a file but what if you over wrote changes that you wanted to keep?

If you are constantly adding data to a server or constantly changing a file or configuration it is best to back up using dates. One example of this is every time I make a change to a Cisco firewall I backup the change with the name of the machine and the current date.

For things that get changed more often and have large amounts of data sometimes its necessary to make a rotation cycle. For example:

Everyday for 1 week (7 backups)
Every week for 1 month (3 additional backups)
Every month for 1 year (11 additional backups)
and for tax purposes every year for 7 years I think (an additional 6 after that)

This leads to a total of 27 backups. While this method doesn't back up EVERY single change it goes with the assumption that you have a week to find a problem before it starts deleting data. The benefit to this is that it takes less space. If you are unconcerned about space then by all means backup and keep every backup.

For Databases:

MySQL backups can be done with a mysql dump. This "dumps" an entire database or databases into a file. You can also do individual tables. An LDAP database is similar in that you dump the database using slapcat (or some other commands).

Once I had to do a different dc for an ldap backup and it caused so differences.
Here are the commands I ran:

 sudo slapcat -b dc=special,dc=com > ldapdumpspecial.raw
 slapadd -l /home/mwaldorf/ldapdumpspecial -b dc=special,dc=com

I will include further instructions on specifics in different posts but I wanted to have this saved somewhere. I do believe before the restore we run:
egrep -v ‘^entryCSN:’ < /root/ldapdump.raw > /root/ldapdump on the

Always remember to restore permissions and SeLinux context. If you do not do this it will not work properly a lot of the time. For windows users backing up a file system can be different. There are various options for backup and recovery.