biocyberman Posted December 5, 2007 Share Posted December 5, 2007 Hello there! I have been searching many hours, have not found anything applicable, so I would like to ask some help. I have a hosting space with thousands of small files in multiple directories. Now I want to migrate them to new host. Obliviously compressing all those files and directories before downloading and uploading to new server can really save a lot of time and troubles (i.e file attributes). Unfortunately I don't have ssh access so I can't use shell command to compress file before download; old hosting provider wouldn't want to provide help. I tried using perl script and several backup classes from phpclasses but they didn't work. Old server is Freedsb, PHP 4.4.1. Could you show me how to do what I describe above? Link to comment https://forums.phpfreaks.com/topic/80229-how-to-compress-multiple-directories-in-webspace/ Share on other sites More sharing options...
PHP_PhREEEk Posted December 5, 2007 Share Posted December 5, 2007 Sorry, don't know of any 3rd party PHP scripts that will do that... surely someone has made one though. What type of control panel is installed? Really though, how much total disk space are we talking about for the entire website? I've been in the position many times to have to archive a site through FTP, and even in the > 1gb range, this goes relatively fast (under 20 mins). So, by the time you do all this research, you could just have the site downloaded to your local machine. PhREEEk Link to comment https://forums.phpfreaks.com/topic/80229-how-to-compress-multiple-directories-in-webspace/#findComment-406676 Share on other sites More sharing options...
biocyberman Posted December 5, 2007 Author Share Posted December 5, 2007 Hi PHREEK, Thanks for your reply. Total size is about 2 Gb. My ftp connection is slow and my computer is Windows XP, so when I copy to my computer before uploading, file attributes are all lost. That's the reason I want to go for compressing before download. I may use this method many times in future and for the sake of learning, I want to know it. Link to comment https://forums.phpfreaks.com/topic/80229-how-to-compress-multiple-directories-in-webspace/#findComment-406759 Share on other sites More sharing options...
aschk Posted December 5, 2007 Share Posted December 5, 2007 Do you have SSH access on your new host? Is so, log into new host (using ssh) then ftp out to your old host, and download the files directly Link to comment https://forums.phpfreaks.com/topic/80229-how-to-compress-multiple-directories-in-webspace/#findComment-406786 Share on other sites More sharing options...
biocyberman Posted December 5, 2007 Author Share Posted December 5, 2007 No I don't have SSH access. That's the problem. Thanks for your reply anyway. Link to comment https://forums.phpfreaks.com/topic/80229-how-to-compress-multiple-directories-in-webspace/#findComment-406790 Share on other sites More sharing options...
trq Posted December 5, 2007 Share Posted December 5, 2007 Put this in a file in your root directory. <?php exec('tar czvf bkp.tar.gz *'); ?> Link to comment https://forums.phpfreaks.com/topic/80229-how-to-compress-multiple-directories-in-webspace/#findComment-406791 Share on other sites More sharing options...
trq Posted December 5, 2007 Share Posted December 5, 2007 Actually, from php you might need to use... <?php exec('/usr/tar czvf bkp.tar.gz *'); ?> Link to comment https://forums.phpfreaks.com/topic/80229-how-to-compress-multiple-directories-in-webspace/#findComment-406794 Share on other sites More sharing options...
jaymc Posted December 5, 2007 Share Posted December 5, 2007 If its just certain folders you want to backup and compress Could put folder names in an array, then do a foreach with the exec tar command in Link to comment https://forums.phpfreaks.com/topic/80229-how-to-compress-multiple-directories-in-webspace/#findComment-406825 Share on other sites More sharing options...
biocyberman Posted December 5, 2007 Author Share Posted December 5, 2007 Thanks all for replies. I tried with following code, browser (Firefox) showed infinite running or popped up a saving file dialogue told me if I want to save "backup.php" file. <?php // Script name: backup.php ini_set("max_execution_time", "300"); echo exec('which tar'); //Just to make sure correct tar path exec("/bin/tar czvf ./backup.tar.gz home/username/public_html/src_dir"); // I know src_dir exists echo "<br /> Backup finished"; ?> I don't know what is wrong ??? Link to comment https://forums.phpfreaks.com/topic/80229-how-to-compress-multiple-directories-in-webspace/#findComment-406850 Share on other sites More sharing options...
trq Posted December 5, 2007 Share Posted December 5, 2007 Your paths don't look right. exec("/bin/tar czvf backup.tar.gz /home/username/public_html/src_dir"); Ive just read your second reply though. Compressing 2G worth of files really is going to be a nightmare. Have you looked at the ftp extension at all. It probably best to simply ftp the files to your new server. Link to comment https://forums.phpfreaks.com/topic/80229-how-to-compress-multiple-directories-in-webspace/#findComment-406893 Share on other sites More sharing options...
biocyberman Posted December 5, 2007 Author Share Posted December 5, 2007 Thanks thorpe, I tweaked around with paths but it didn't work. ftp extension would be a good try. I will come back on any updates. Link to comment https://forums.phpfreaks.com/topic/80229-how-to-compress-multiple-directories-in-webspace/#findComment-406928 Share on other sites More sharing options...
biocyberman Posted December 9, 2007 Author Share Posted December 9, 2007 Hello, With ssh access to my new web space I managed to do transfer with wget command at very high speed. I also got advice on how to use perl to work for what I want (http://perlguru.com/gforum.cgi?post=29170). I don't know why the same shell command works when put in perl, but doesn't work when put in PHP exec() though. Maybe because of permission setting. Link to comment https://forums.phpfreaks.com/topic/80229-how-to-compress-multiple-directories-in-webspace/#findComment-410208 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.