FTP镜像与Codeigniter创建文件夹,但没有上传文件

时间:2023-02-15 00:28:13

I am using Codeigniter to backup mysql tables and write the sql file to the local webserver's htdocs/application/backups directory.

我使用Codeigniter来备份mysql表并将sql文件写入本地webserver的htdocs / application / backups目录。

I want that directory to be mirrored on my remote webserver (dreamhost backups user account) but it's not working, I'm not seeing the sql files in the remote directory.

我希望在我的远程网络服务器(dreamhost备份用户帐户)上镜像该目录,但它无法正常工作,我没有在远程目录中看到sql文件。

I'm using CI's FTP library and it's mirror() function to copy the contents of my local backups directory to my remote server.

我正在使用CI的FTP库,它的mirror()函数将我本地备份目录的内容复制到我的远程服务器。

In my database backup model I set variables to use in the scrip:

在我的数据库备份模型中,我设置要在脚本中使用的变量:

private $local_folder = 'my_directory/';
private $server_folder = 'my_server_directory/';
private $server_credentials = array(
    'hostname'=>'my.hostname.com',
    'username'=>'my_username',
    'password'=>'my_password'
    );

Also in the database backup model I have the mirror function:

另外在数据库备份模型中我有镜像功能:

function mirror(){
    $this->load->library('ftp');
    $this->ftp->connect($this->server_credentials);
    $result = $this->ftp->mirror($this->local_folder,$this->server_folder);
    var_dump($result); //shows "true" 
    $this->ftp->close();
}

I call the mirror() from my backup function. The sql files are created and stored locally by the backup function, but the local folder isn't mirrored to the webserver.

我从备份函数中调用mirror()。 sql文件由备份功能在本地创建和存储,但本地文件夹不会镜像到Web服务器。

the remote backup directory permissions are '777' and test runs of $this->ftp->list_files and $this->ftp->mkdir() work just fine.

远程备份目录权限为'777',测试运行$ this-> ftp-> list_files和$ this-> ftp-> mkdir()工作正常。

Any ideas why files won't be uploaded?

任何想法为什么不上传文件?

2 个解决方案

#1


1  

I'm posting an answer to my own question because the problem was my own ignorance.

我正在回答我自己的问题,因为问题是我自己的无知。

private $server_folder = 'my_server_directory/';

private $ server_folder ='my_server_directory /';

should have been

本来应该

private $server_folder = '/my_server_directory/';

private $ server_folder ='/ my_server_directory /';

I swear I tried that syntax while trouble shooting my problem, but I must have changed something else too that broke the mirroring at the same time, hiding the answer from me.

我发誓我在解决问题的同时尝试了这种语法,但我必须改变别的东西,同时打破了镜像,隐藏了我的答案。

Thanks for your comments and answers @Damien Pirsy and @ Edinho Almeida.

感谢您的评论和答案@Damien Pirsy和@ Edinho Almeida。

#2


0  

If

$this->ftp->mkdir()

works fine, I'm sure that your permission settings are ok.

工作正常,我确定你的权限设置没问题。

If

$this->ftp->list_files()

works fine, I'm sure that your connection settings are ok too.

工作正常,我确信您的连接设置也可以。

I guess your SQL backup files are starting with dot

我猜你的SQL备份文件是以dot开头的

See in

system/libraries/Ftp.php at lines 547 and 551

#1


1  

I'm posting an answer to my own question because the problem was my own ignorance.

我正在回答我自己的问题,因为问题是我自己的无知。

private $server_folder = 'my_server_directory/';

private $ server_folder ='my_server_directory /';

should have been

本来应该

private $server_folder = '/my_server_directory/';

private $ server_folder ='/ my_server_directory /';

I swear I tried that syntax while trouble shooting my problem, but I must have changed something else too that broke the mirroring at the same time, hiding the answer from me.

我发誓我在解决问题的同时尝试了这种语法,但我必须改变别的东西,同时打破了镜像,隐藏了我的答案。

Thanks for your comments and answers @Damien Pirsy and @ Edinho Almeida.

感谢您的评论和答案@Damien Pirsy和@ Edinho Almeida。

#2


0  

If

$this->ftp->mkdir()

works fine, I'm sure that your permission settings are ok.

工作正常,我确定你的权限设置没问题。

If

$this->ftp->list_files()

works fine, I'm sure that your connection settings are ok too.

工作正常,我确信您的连接设置也可以。

I guess your SQL backup files are starting with dot

我猜你的SQL备份文件是以dot开头的

See in

system/libraries/Ftp.php at lines 547 and 551