Backing up Projects & Databases
Projects Backup
In the event we need to reference anything that was ever on RHEL 6 (projects, that is), it would be wise to have a tarball of all artifacts under /apps folder, as well as all the databases that were created for each of the projects...
Gone are the days where SFTP'ing into the server and then selecting folders & files and clicking on download... only to wait hours!! for the tool (e.g. FileZilla) to download them one by one by one by... Luckily, we have the tar command at our disposal!
Below are some of the adventures (wasn't capturing screenshots earlier on... so this is towards the tail-end of the backup journey. In hindsight, I should have... as this was indeed an adventure!)
The following dirs were explicitly excluded from the tarball — they are too big and I kept running out of space on the disk—oh and they are standard client installs... no modifications were done to these so...
- /apps/oracleClient
- /apps/client
- /apps/archive/oracleClient_old
And as such, we have our tar command as follows:
tar -zcvf RHEL_6-Apps_Dir.tar.gz /apps/ --exclude="/apps/oracleClient" --exclude="/apps/client" --exclude="/apps/archive/oracleClient_old" --exclude="/apps/
5mins later:
Huh??!! WHAT errors? ARggHhh!! Let's get rid of the "v" flag... so we can see what these errors are!
rm -rf RHEL_6-Apps_Dir.tar.gz clear tar -zcf RHEL_6-Apps_Dir.tar.gz /apps/ --exclude="/apps/oracleClient" --exclude="/apps/client" --exclude="/apps/archive/oracleClient_old" --exclude="/apps/
(missing screenshot) but basically, some folders didn't have the the correct permissions... so...
ksu cd /home/rjb03001 tar -zcvf RHEL_6-Apps_Dir.tar.gz /apps/ --exclude="/apps/oracleClient" --exclude="/apps/client" --exclude="/apps/archive/oracleClient_old" --exclude="/apps/
Perfect! Was able to create a tarball successfully!
Now... the databases
I went through the phpMyAdmin interface and exported each database individually... but, I wanted to try the same via the command line interface, using the `mysqldump` command... After some (quick) research, I came across the following discussion on SO, which made sense and proved to be a good solution! — specifically, this response.
In order to do a comprehensive backup, the following command was used in the CLI
mysqldump -u root -p -A -R -E --triggers --single-transaction > full_backup.sql
Got the following error:
mysqldump: Got error: 1045: Access denied for user 'root'@'localhost' (using password: YES) when trying to connect
Wait... what?! Access denied for root user?
I proceeded to create a new user, called it backup and granted access to all databases on RHEL6.... and then here's the result:
mysqldump -u backup -p -A -R -E --triggers --single-transaction > full_backup.sql