Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
339 views
in Technique[技术] by (71.8m points)

ftp - Web site backup in PHP?

Does anybody know a clean PHP-based solution that can backup remote web sites using FTP?

Must haves:

  • Recursive FTP backups
  • Possible to run through a cron job
  • Easy to configure (easy adding of multiple sites)
  • Local storage of backup files is sufficient

Would be nice:

  • Backed up sites are stored as zip files
  • A nice interface to manage things
  • Provides notification when backup has succeeded or failed
  • Does incremental backups
  • Does MySQL Database backups

I need this to be PHP based because it's going to be used on shared hosting packages that do not allow usage of the standard GNU/Linux tools.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I have done something like this in a cron job PHP script before. Not sure if it is the best way, but it certainly works.

$backup_file = '/home/example/sql_backup/mo_'.date('Y-m-d').'.sql.gz';
$command = '/usr/bin/mysqldump -c -h'.DB_HOST.' -u'.DB_USER.' -p'.DB_PASS.' --default-character-set=latin1 -N '.DB_NAME.' | gzip > '.$backup_file;
exec($command);

You could then exec an sftp to the remote server.

You could do the file folders similarly using exec() and linux zipping.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...