ALERT!
Click here to register with a few steps and explore all our cool stuff we have to offer!
Home
Upgrade
Credits
Help
Search
Awards
Achievements
 3163

How to backup and restore your forum (Linux / Windows)

by Bi0S - 05-04-2017 - 02:59 AM
#1
Note that many hosts handle backups and restores automatically. You can choose to rely on your host if you want. This guide is about manual backups and restores.

Sections below:
- Linux Server Backup
- Linux Server Restore
- Windows Server Backup
- Windows Server Restore

__________

Linux Server Backup

You need to backup your database and your files. Both are equally important. You should backup both at the same time and keep them together.

Backup Using Shell Access

I highly recommend using a shell connection to make a backup. Sometimes you have to ask your host to enable shell access. You also need a shell client to make the actual connection. Putty is a popular shell client.

1) Backing up the database.

Here is the shell command for backing up your database. You need to replace the CAPITALIZED portions with your own info. The database information is in your library/config.php file. I prefer to use a full server path for the location of the backup.sql file:

mysqldump --opt -uUSERNAME -pPASSWORD DBNAME > /PATH/TO/backup.sql

If the host is not 'localhost' then you need to specify that in the command as well:

mysqldump --opt -hHOST -uUSERNAME -pPASSWORD DBNAME > /PATH/TO/backup.sql

2) Backing up the files.

With shell access you can make a compressed tarball of the files together with the database. Here is the command that I use to do this. For this command I am assuming we have already created backup.sql with the previous command. As before, you need to replace the CAPITALIZED portions with your own info:

tar -cf - /PATH/TO/backup.sql /PATH/TO/FORUMDIR/ | gzip -c > /PATH/TO/backup.tar.gz

Now you can download the backup.tar.gz file to your computer to have a local backup.


Backup Using Other Means

Without shell access it can be harder to make a proper backup. The alternative backup methods can be unreliable sometimes resulting in incomplete backups.

1) Backing up the database.

You can use phpmyadmin to create a database backup. Phpmyadmin is a free program that allows you to manage your database. Many hosts will preinstall this program for you. Once you are logged in to phpmyadmin you just need to select your database in the left column and then click the Export tab on the top right. Select all tables for export and click the Go button on the bottom. It will download the backup to your computer. This can take a while depending on the size of the database and the speed of your connection.

2) Backing up the files.

Use a FTP program to download your forum directory. This can take a long time if you have a lot of attachments on your forum.




Linux Server Restore

Basically you need to restore the database backup to a database on the server. Then you need to put the forum files in place. Then edit the library/config.php file to point to the database.

Restore Using Shell Access

Shell access is often required to restore a backup unless your backup is very small. You can ask your host to enable shell access. You also need a shell client to make the actual connection. Putty is a popular shell client.

If you followed the shell backup instructions above then you will need to untar/unzip the backup in order to get at the forum files and database backup. I usually copy or move the tar.gz file to it's own directory and then run these commands:

gzip -d backup.tar.gz
tar -xf backup.tar

Now the database backup and forum files are ready to be restored.

1) Restoring the database.

Here is the shell command for restoring your database. You need to replace the CAPITALIZED portions with your own info. It is best to restore to an empty database:

mysql -uUSERNAME -pPASSWORD DBNAME < /PATH/TO/backup.sql

If the host is not 'localhost' then you need to specify that in the command as well:

mysql -hHOST -uUSERNAME -pPASSWORD DBNAME < /PATH/TO/backup.sql

2) Restoring the files.

With the forum files already on the server you just need to move them into place. Here is the command to move the directory. As before, you need to replace the CAPITALIZED portions with your own info:

mv /PATH/TO/BACKUP/FORUMDIR/ /PATH/TO/WEBROOT/

3) Edit the config file.

Now you need to edit the library/config.php file to point to the database to which you restored the database backup.


Restore Using Other Means

Without shell access you can try using other means to restore the backup. But these other methods don't always work.

1) Restoring the database.

You can use phpmyadmin to restore the database. Phpmyadmin is a free program that allows you to manage your database. Many hosts will preinstall this program for you. Once you are logged in to phpmyadmin you need to select your database in the left column and then click the Import tab on the top right. Browse to your database backup file on your computer and then click Go on the bottom. This can take a while depending on the size of the database and the speed of your connection.

2) Restoring the files.

Use a FTP program to upload your forum directory. This can take a long time if you have a lot of attachments on your forum.

3) Edit the config file.

Now you need to edit the library/config.php file to point to the database to which you restored the database backup.




Windows Server Backup

You need to backup your database and your files. Both are equally important. You should backup both at the same time and keep them together.

Backup Using Remote Desktop

Windows servers often come with remote desktop access (RDP) which makes backups easy. You will need a RDP client. Every Windows PC has a RDP client. If you are on Mac OS X then you can use CoRD.

1) Backing up the database.

Here is the command for backing up your database. This command can be run in the Windows command prompt through RDP. You need to replace the CAPITALIZED portions with your own info. The database information is in your library/config.php file. I prefer to use full paths for all locations:

"C:\PATH\TO\MYSQL\bin\mysqldump.exe" --opt -uUSERNAME -pPASSWORD DBNAME > "C:\PATH\TO\backup.sql"

If the host is not 'localhost' then you need to specify that in the command as well:

"C:\PATH\TO\MYSQL\bin\mysqldump.exe" --opt -hHOST -uUSERNAME -pPASSWORD DBNAME > "C:\PATH\TO\backup.sql"

2) Backing up the files.

With RDP access you can simply make a copy of the forum directory using the Windows desktop environment as you would on any Windows PC. I recommend creating a zip file with both the database backup and the forum files.


Backup Using Other Means

Without RDP access it can be harder to make a proper backup. The alternative backup methods can be unreliable sometimes resulting in incomplete backups.

1) Backing up the database.

You can use phpmyadmin to create a database backup. Phpmyadmin is a free program that allows you to manage your database. Many hosts will preinstall this program for you. Once you are logged in to phpmyadmin you just need to select your database in the left column and then click the Export tab on the top right. Select all tables for export and click the Go button on the bottom. It will download the backup to your computer. This can take a while depending on the size of the database and the speed of your connection.

2) Backing up the files.

Use a FTP program to download your forum directory. This can take a long time if you have a lot of attachments on your forum.




Windows Server Restore

Basically you need to restore the database backup to a database on the server. Then you need to put the forum files in place. Then edit the library/config.php file to point to the database.

Restore Using Remote Desktop

Windows servers often come with remote desktop access (RDP) which makes restores easy. You will need a RDP client. Every Windows PC has a RDP client. If you are on Mac OS X then you can use CoRD.

1) Restoring the database.

Here is the command for restoring your database. This command can be run in the Windows command prompt through RDP. You need to replace the CAPITALIZED portions with your own info. It is best to restore to an empty database:

"C:\PATH\TO\MYSQL\bin\mysql.exe" -uUSERNAME -pPASSWORD DBNAME < "C:\PATH\TO\backup.sql"

If the host is not 'localhost' then you need to specify that in the command as well:

"C:\PATH\TO\MYSQL\bin\mysql.exe" -hHOST -uUSERNAME -pPASSWORD DBNAME < "C:\PATH\TO\backup.sql"

2) Restoring the files.

With RDP access you can simply copy the backup of the forum directory to the web root using the Windows desktop environment as you would on any Windows PC.

3) Edit the config file.

Now you need to edit the library/config.php file to point to the database to which you restored the database backup.


Restore Using Other Means

Without RDP access you can try using other means to restore the backup. But these other methods don't always work.

1) Restoring the database.

You can use phpmyadmin to restore the database. Phpmyadmin is a free program that allows you to manage your database. Many hosts will preinstall this program for you. Once you are logged in to phpmyadmin you need to select your database in the left column and then click the Import tab on the top right. Browse to your database backup file on your computer and then click Go on the bottom. This can take a while depending on the size of the database and the speed of your connection.

2) Restoring the files.

Use a FTP program to upload your forum directory. This can take a long time if you have a lot of attachments on your forum.

3) Edit the config file.

Now you need to edit the library/config.php file to point to the database to which you restored the database backup.
Reply

Users browsing: 1 Guest(s)