Shell SSH access to the server is recommended for backups. Use Putty for windows and Terminal for Mac to execute the backup commands. Often shell SSH access is disabled on shared hosting and you may need to enable it.
Once you are logged into the SSH, change the directory with CD command to public_html directory. If you aren’t sure the exact path to your public_html directory, upload a temp.php file with following.
Now run the file in a browser and it will show the path to the public_html directory. As a security tip, it isn’t recommended to have the temp.php file on the web server.
Browse to the right folder using the CD command
> CD /path/to/public_html
> CD ..
Backup MySQL database using mysqldump command. Replace USERNAME and PASSWORD with your own info.
> mysqldump -uUSERNAME -p'PASSWORD' --all-databases > ./dbase.sql
Zip the backup SQL file created.
> gzip dbase.sql
Now create a tar file of all the files inside the public_html folder.
> tar cvf files.tar /path/to/public_html/*
Zip the tar file
> gzip files.tar
Now you will have a couple of files aka
- files.tar.gz which contains all the files to XenForo
- dbase.sql.gz which contains the database backup.
The full backup of XenForo is complete.
Server to Server Move
The above files can be saved to a remote FTP server using the FTP commands which can save you the pain to download large files.
> FTP IP_OR_DOMAINNAME
And then it prompts for username and password for the remote FTP connection.
Now at the FTP command prompt one can do a put command to transfer the backup files to the FTP server.
FTP> put dbase.sql.gz
FTP> put files.tar.gz
Depending on the size of the backup files, it may take some time for each of the above commands to complete. Once complete, you will have both the files transferred over to the other server.
If you wish to create folders to keep the backup files, you can do that using these basic FTP commands.
Restoring the files and database from the above files is simple. Unzip the database file.
> gunzip dbase.sql.gz
Login to MySQL prompt
> mysql -uUSERNAME -p'PASSWORD'
Now change the database using the following MySQL command. If you do not have the database created, you can do so using this guide.
mysql> use DATABASENAME;
Now use the source command to restore the backup in the database.
mysql> source dbase.sql
The process will start executing the SQL commands from the file. Depending on the size of the backup, the process can take a long time.
Once complete exit the MySQL prompt with exit command.
Now move files.tar.gz into the public_html folder.
> mv files.tar.gz path/to/public_html
Again if you aren’t sure of the path to public_html, you can use the temp.php file in the backup step to get the path to the public_html folder.
> gunzip files.tar.gz
This will uncompress the .gz file into a .tar file. Now untar the files.tar file
> tar xvf files.tar
Edit the config.php file to connect the new database.