FTP move folder in another server to another server
I have 3 server:
main server: laravel8, ubuntu 18.04, php7.4.
another server A: ubuntu 18.04, FTP server installed
another server B: ubuntu 18.04, FTP server installed
i want make command laravel (main server)
- move folder from server A to server B
- delete that folder in server A after move complete
Thanks!
i think u can use
copy('ftp://user:[email protected]/path/to/file', 'ftp://user:[email protected]/path/to/file')
or
file_put_contents('ftp://user:[email protected]/path/to/file', file_get_contents('ftp://user:[email protected]/path/to/file'))
for copy files.
in total you can use standart Storage class for list ftp files, copy from ftp to ftp as i says and remove from ftp with Storage.
some kind of vinaigrette... but i think it is simplest and fastest method.
With ftp you have do 'double move*' file per file all your files in your folder (and sub folders if any)
- retrieve the file from A to your main server and then put it on your server B
- check for any error
And the end, if no error, delete folder in A
https://github.com/harishanchu/Laravel-FTP
Couldn't you install and use ssh/scp/rsync? It should be easier, more secure and more reliable.
thanks for reply
if use use ssh/scp/rsync, how it works (i want control with laravel command + schedule)
because move folder in another server to another server. then
shell_exec('ssh root@serverB rsync OPTION SourceDirectory_or_filePath user@serverA:Target')
It will be complicated if the number of files is large.
Hi @trin
and for me +1 for 'some kind of vinaigrette' :-)
test your command drectly first (have ssh log without passwd)
It will be complicated if the number of files is large.
Use job in Laravel for such task.
Please or to participate in this conversation.