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
200 views
in Technique[技术] by (71.8m points)

php - Backup, restore database from neighbor

These functions can backup, restore database in local win10.

public function dump($datetime) {
  if (empty($datetime)) {
    $datetime = date('YmdHis');
  }
  set_time_limit(0);
  $drive = mb_substr(__DIR__, 0, 1, 'utf8');

  $exe = $drive.':/xampp/mysql/bin/mysqldump --user='.DB_USERNAME.' --password='.DB_PASSWORD.' --host='.DB_HOSTNAME.' '.DB_DATABASE.' > '.
  __DIR__.'/../_upload/sql/'.DB_DATABASE.$datetime.'.sql';
  @exec($exe);
}

/**
* @param file __DIR__.'/../_upload/sql/'.DB_DATABASE.$datetime.'.sql'
*/
public function import($file) {
  if (is_file($file)) {
    set_time_limit(0);
    $drive = mb_substr(__DIR__, 0, 1, 'utf8');

    $exe = $drive.':/xampp/mysql/bin/mysql --user='.DB_USERNAME.' --password='.DB_PASSWORD.' '.DB_DATABASE.' < '. $file;
    
    @exec($exe);
  }
}

I want to backup database to the NAS so I replaced D:xampphtdocspj\_uploadsql to ftp://user:[email protected]/pj/_upload/sql in httpd-xampp.conf but apache can't start. Is there a way to soft link a ftp folder for php to read and write?

Alias /pj/_upload/sql "ftp://user:[email protected]/pj/_upload/sql/"
<Directory "ftp://user:[email protected]/pj/_upload/sql">
    AllowOverride AuthConfig
    Require all granted        
</Directory>
question from:https://stackoverflow.com/questions/65838717/backup-restore-database-from-neighbor

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

1 Answer

0 votes
by (71.8m points)
Waitting for answers

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

...