Jump to content

Restoring my CPanel Full Backup from home directory


Rostamiani

Recommended Posts

Guest Geoff

Actually, the problem was that he did not own the files in his home directory [they were owned by a user id from his old server, so:

 

# chown -R rostamia .
#chgrp -R rostamia .

 

Afterwards, I needed to restore his mysql backup. I was afraid that if I restored it with root permissions, it might contain malicious code. So, instead I created a php file with the following code:

 

<?php

function SplitSQL($file, $delimiter = ';')
{
    set_time_limit(0);

    if (is_file($file) === true)
    {
           $file = fopen($file, 'r');

           if (is_resource($file) === true)
           {
            $query = array();

            while (feof($file) === false)
            {
                   $query[] = fgets($file);

                   if (preg_match('~' . preg_quote($delimiter, '~') . '\s*$~iS', end($query)) === 1)
                   {
                    $query = trim(implode('', $query));

                    if (mysql_query($query) === false)
                    {
                           echo '<h3>ERROR: ' . $query . '</h3>' . "\n";
                    }

                    else
{
                         echo '<h3>SUCCESS: ' . $query . '</h3>' . "\n";
                    }

                    while (ob_get_level() > 0)
                    {
                         ob_end_flush();
                    }

                    flush();
                }

                if (is_string($query) === true)
                {
                    $query = array();
                }
            }

            return fclose($file);
        }
    }

    return false;
}

echo 'hello';

$file = '/home1/rostamia/mysql_backup/mysql/rostamia_smf.sql';

mysql_connect('localhost', 'rostamia_smf', '****');

mysql_select_db('rostamia_smf');

echo 'hello';

SplitSQL($file);

echo 'hello';

mysql_close();

 

 

Note that I did already have that function on hand, I didn't write it just for him.

 

 

Then, I edited his config file, added the forum subdomain, and found that it was working.

 

Only have to wait 24 hours for the subdomain to be added.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...