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

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.

About the Author...

Jennifer Zelazny

My name is Jennifer Zelazny and this site is a collection of my random thoughts and opinions. I am Penn Stater, WordPress developer, and a modern day explorer. I love exploring data, trends, and things that make the world a better place and sharing them here.

Leave a Reply

Your email address will not be published.
*
*
You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>