Backup and restore from shell
Task
Backing up and restoring files and database data for a website hosted on Linux.
Explanation
To backup the file structure from shell, use the following command:
tar cfz backup.tar.gz ./*
This will backup all files in the current directory – it will create the archive ready to restore in the directory as well (It will not created nested folders starting from root).
To restore a backup use the following command:tar xfz backup.tar.gz
To backup an SQL database from shell, use the following command:
mysqldump -hHOST -uUSERNAME -pPASSWORD DATABASENAME > BACKUPFILE.sql
To restore an SQL database, use the following command:
mysql -h HOSTNAME -u USERNAME -pPASSWORD DATABASE < FILE.sql
Thanks
N/a