If your dedicated server doesn’t have a control panel, or you just prefer working from the command line, SSH gives you full control over backing up both your files and your databases. Here’s how to do it properly, that’s actually usable if you ever need to restore from it.
Connect to your server via SSH using your terminal (Mac/Linux) or a client like PuTTY (Windows):
bash
ssh username@your-server-ip
A quick security note: logging in directly as root works, but it’s better practice to SSH in as a regular sudo-enabled user and use sudo for privileged commands. If your server still only allows root login, consider setting up a separate admin user and disabling direct root SSH access once you’re comfortable with the process.
Export database to .sql file via mysqldump:
bash
mysqldump -u your_username -p your_database_name > backup_$(date +%F).sql
You’ll be prompted for your MySQL password. The $(date +%F) part of commands automatically adds today’s date at the end of the filename, for example, backup_2026-08-07.sql. Due to which you can easily find the right backup later.
bash
mysqldump -u your_username -p –all-databases > all_databases_$(date +%F).sql
A database backup alone doesn’t back up your actual website files, uploads, or configuration. Use tar to archive a directory:
bash
tar -czvf website_backup_$(date +%F).tar.gz /var/www/html
This compresses everything in /var/www/html (adjust the path to wherever your website actually lives) into a single .gz file.
This is the step the original process skipped, and it’s the one that actually matters. A backup that lives only on the same server doesn’t protect you if that server has a hardware failure, gets compromised, or is lost entirely. Copy backups somewhere else using scp or rsync:
bash
scp backup_2026-08-07.sql user@remote-server:/path/to/backup/folder/
Or sync a whole backup directory with rsync:
bash
rsync -avz /home/backups/ user@remote-server:/backups/
Manual backups get forgotten so automate the backup process:
bash
crontab -e
Add a line to run a database backup daily at 2 AM:
bash
0 2 * * * mysqldump -u your_username -p’your_password’ your_database > /home/backups/db_$(date +\%F).sql
Note: storing a plaintext password in a cron job isn’t ideal from a security standpoint. Therefore, store credentials in a .my.cnf file with restricted permissions (chmod 600) and omit the password from the command entirely, because it is a more secure approach for it.
Database:
bash
mysql -u your_username -p your_database_name < backup_2026-08-07.sql
Files:
bash
tar -xzvf website_backup_2026-08-07.tar.gz -C /var/www/html
If you are unsure about how to back up your data properly, or facing issues while backing up your data, then reach out to our support team or chat with us.