MainWP Community

Can't backup the database with CodeGuard setup

Hello,

First of all, thank you @dennis for the free one year coupon to test out CodeGuard!

Now, I tried to setup my MainWP Dashboard with CodeGuard, I was able to connect to the SFTP but, for the database, it requests access to the hostname of the DB. Mine is not accessible publicly, I can only access it via the Cpanel. I checked the SSH solution but super complicated… Did I miss something?

Because with UpdraftPlus, we can just setup the backup schedule, what type (full or DB) and all good to go. You can also specify an external source to save it.

So, is there any simpler way to setup the DB backup?
Thanks,
Fred

I assume you already attempted whitelisting CodeGuards IP’s.

CodeGuard is active above your WordPress site, unlike UPDraft, which is a plugin that relies on WordPress to work. So in your situation where the Database is not accessible, you will need to use SSH to access your Database.

Have you also looked over this article?

Which part of the steps, exactly are you having trouble with, and someone with more server experience like Keith @kwcjr can probably help.

DB server not accessible publicly, so no need of whitelisting…

That is my issue, it is too complicated and never use SSH connection.
I tried that: https://codeguard.zendesk.com/hc/en-us/articles/115000587986-Database-Backup-through-SSH-Tunneling-WebHostingBuzz-Example and failed…

My concern is that I will have to do this for every single clients (+75), time consuming!

Please, give me a a bit - I am attempting to make you a video on how to connect your DB.

It would be helpful if we knew what Hosting company this “inaccessable” DB is on. Technically your DB MUST HAVE an I.P. that is accessible to the public or it would never be able to be used by wordpress in the first place. It’s most likely a port or a separate IP all together like Siteground does for connecting to DB over SSH.

Also, if you are using CG’s Public Key, they are different for each connection; You will have two per site that you connect to. One for the SFTP and one for the SSHTunnel. My suggestion to get around needing two for each connection is to make a MASTER key pair yourself and upload THAT to CG. I have not tested this yet so please give me time.

Or to simplify the entire process you can use the WP Plugin that CG provides and you will be connected through that via SHH Key Pairs as well. It’s just Automated. I have tested this and it works fine.

Thank you for your Patience I will have a rough video for you here soon.

2 Likes

Thanks @kwcjr. I will wait for the video then. I already connected successfully via sftp.

Thank you for waiting.

I have been on support myself with my Hosting Company Sitegrounds since I took on this ticket. I don’t think I will be able to make a video on how to use SSH Tunnel to connect at this time. I have gone over my entire setup with Siteground and they have confirmed that all settings within CG are correct but I am getting an error “Lost connection. The connection to your MySQL server was lost or killed.”

So far I know how to correctly generate Private/Public Keypairs, Upload them and get CG to connect via SFTP
This would be the best solution to lessen the amount of KeyPairs you would need to generate in order to connect to your Child Sites SFTP at least.

I can also tell you the correct information to enter into CG SSH Tunnel in order to connect but it’s simply not working at this time for my server; It may for yours… Update found out why waiting for answer from SG

I’m sorry I don’t have a better answer for you at this moment. SSH is not a novice task & sometimes you have to work with your Hosting company if things don’t work right away.

In the mean time,

You can simply use MySQL Direct to connect to the Database. You would only need your wp-config.php credentials to connect. That’s what I am currently doing myself.

So you have the same information I do - These are the steps I took to connect via SSH Tunnel

Private Key (Note: CodeGuard only supports unencrypted RSA and DSA keys so do NOT use a passphrase when asked )

1.) Create a Public/Private Keypair via ssh-keygen ( So you are not forced by your host to Encrypt it with a passphrase; most do )

Within Windows PowerShell OR Linux Terminal type the command:
$ ssh-keygen -t rsa

Open those two files in a Text Editor of your choice
   id_rsa        is your Private Key that you use on CG
   id_rsa.pub    is your Public Key that you put on your server

2.) Install the public key as an authorized key on your server

Log into cPanel
search for SSH
upload your Public Key

3.) Upload your Private key to CodeGuard

Username is your cPanel Name
Password is your cPanel Password

[Siteground Caviat] - SSH port is 18765

Database Connection

4.) Whitelist CG within MySQL


Go back to cPanel
Search for “Remote MySQL”
Add CG IPS
54.174.115.171
54.174.153.212
54.174.91.34
54.236.233.28
54.236.233.46

5.) Open your Wp-config.php for MySQL Creds

Database Hostname: Usually your server IP
Enter in Database Name
Enter in Database Password
MySQL Port keep 3306
ssh username cPanel
ssh password cPanel
click add private key & paste your private key in again

[Siteground Caviat] - SSH port is 18765
[Siteground Caviat] - Database Hostname Not Server IP  ( see "Remote MySQL" cPanel Tool )

[Update] - I found this article on CG that covers connecting through SSH Tunnels if you know your credentials are right but still can’t connect which is the issue that I am having: I can’t connect using a SSH tunnel, but I know my credentials are correct – Support Center

I was unable to Grant Rights so I am waiting to hear back from SG Technical Team to see if they can add it. The directions above should work if your Host Allows it & you have uploaded your keys correctly & are using the correct login details. However, every server is different.

Thanks @kwcjr - I am going to try this solution which seems the simpler since I am not confortable with SSH.

1 Like

@wpexpert You’re welcome. It’s not always a straight forward task and is almost always different on each Server/Host. It sometimes takes trial and error & working with your hosting company till you get the right combination.

You shouldn’t have any issues with the Plugin.

1 Like

Hi Keith,
I tried the plugin solution following those instructions: https://codeguard.zendesk.com/hc/en-us/articles/115000621403-How-do-I-install-the-WordPress-plugin-
I am stuck at the “Unique Access Key” because, in my dashboard, I have no option to Add a WordPress website! https://share.getcloudapp.com/WnuE57NK
Probably needs to contact CodeGuard support… They don’t make easy!

@wpexpert Please make sure you are logged into your CodeGuard.com Dashboard
then follow this link: Set URL You should be taken to the correct page.

2 Likes

That is the easiest solution to add a WordPress site to CodeGuard! Thanks @kwcjr. I selected it as the solution for my problem.

2 Likes

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.