Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
346 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 Reply

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...