Jump to content

Recommended Posts

Hey..

 

I'm trying to make something for someone, this requires the server, using a crontab to make a backup of all the files, and maybe also the mysql database.

 

I thought I will use Zip to archive the files/dictionaries, and then upload it to another remote ftp server.

I have the Ftp working, it makes connection and sends files.

 

But here comes my problem, how can I zip the files, and the dictionaries?

It would require a check to see if it is a dir, if it is, then loop trough that dir and upload those files.

How can I achieve this?

 

Here is a script I tried to make to just upload the files via Ftp, This is creating dictionaries and the root files, btu not uploading the files within the sub folders.

 

<?php



$FtpServer = 'server';
$FtpPort = 21;
/* Password and user comes here.. */
$FtpDir = '/narc0de/';
$dir = 'c:\wamp\www\ziptest\narc0de';
$Stream = ftp_connect($FtpServer, $FtpPort,60);
$Login = ftp_login($Stream, $FtpUser, $FtpPasswd);
if (!$Login || !$Stream){
	echo 'Login or Connection Failed.';
	exit; }
       if (is_dir($dir)) { if ($dh = opendir($dir)) { while (($file = readdir($dh)) !== false ) { echo $file; $i++;
                       if( $file != "." && $file != ".." )
                       { $nowd = ftp_pwd($Stream);
                         $Do = ftp_put($Stream, $file, $nowd.$file, FTP_BINARY); } }
               closedir($dh); } }

if (isset($Do)){
	echo 'Uploaded backup.'.$i;
}
else {
	echo 'Upload Failed.';
}
ftp_close($Stream);
exit;

?>

 

Thanks

Ferdi

Link to comment
https://forums.phpfreaks.com/topic/67089-solved-making-backups/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

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.   Restore formatting

  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...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.