使用 Codeigniter 进行 FTP 镜像创建文件夹,但未上传文件

发布于 2024-11-19 16:15:03 字数 1168 浏览 0 评论 0原文

我正在使用 Codeigniter 备份 mysql 表并将 sql 文件写入本地 Web 服务器的 htdocs/application/backups 目录。

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

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

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

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'
    );

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

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();
}

我调用镜像() 来自我的备份功能。 sql 文件是由备份功能在本地创建和存储的,但本地文件夹不会镜像到网络服务器。

远程备份目录权限为“777”,并测试运行 $this->ftp->list_files$this->ftp->mkdir()工作得很好。

知道为什么文件无法上传吗?

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

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.

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.

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.

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

Any ideas why files won't be uploaded?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

波浪屿的海角声 2024-11-26 16:15:03

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

private $server_folder = 'my_server_directory/';

应该是

private $server_folder = '/my_server_directory/';

我发誓我在解决问题时尝试了该语法,但我肯定也改变了其他东西,同时破坏了镜像,向我隐藏了答案。

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

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

private $server_folder = 'my_server_directory/';

should have been

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.

久光 2024-11-26 16:15:03

如果

$this->ftp->mkdir()

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

如果

$this->ftp->list_files()

工作正常,我确信您的连接设置也没有问题。

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

请参阅

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

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

See in

system/libraries/Ftp.php at lines 547 and 551
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文