Quick Site Backup (files and database) Via the Command Line

Hints HOWTOs UNIX

If you do any sort of web development, it is more than likely that CPANEL and phpMyAdmin are good friends of yours…and you depend on them. Even though those are extremely handy to create/modify databases and create backups, it is extremely helpful to know how to do the same thing by using only SSH and command line utilities.

To backup (export) a database using the command line interface (CLI):

mysqldump -p --user=username --add-drop-table database > backup.sql

You will then need to provide your database password and the exported data will go into a file called “backup.sql” which is located in the directory that you are currently in. (more mysqldump documentation

To backup your files:

tar -cvzf backup.tgz directoryname

The command will create an archive of all your files so you can easily move or store one file (the archive). More tar documentation.

Leave a Reply

Your email address will not be published.
*
*

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Business Life

Career Night Speaker at Penn State

I will be back in State College, PA in April to speak at the History Department Career Night. So, if any of you State College folks are around, I would love to get together with you while I am there (email me about my arrival/departure). I will be talking about my career outside of the […]

Stuff

My Next 3 Wood: PING G10

It is freezing outside so I thought I would post about golf to warm up a bit. Over the last three or four years, I have replaced every single club in my golf bag. I have thoroughly enjoyed all my clubs (PING G2 irons 2-S, Titleist 975J driver, PING G5 putter), but I have not […]