(Turkish) Codeigniter Date Helper Kullanımı

(Turkish) Codeigniter Captcha Kullanımı

(Turkish) Codeigniter Array Helperı Kullanımı

Codeigniter Controller’dan View Veri Aktarma

Getting and Maintaining a MySQL Database Backup with PHP

PHP Programming Saturday April 28th, 2018
956 Görüntülenme

Perform simple and fast MySQL backup/restore using PHP. You can use it to dump a full database or only some tables.

It requires PHP 5.0.5 or later.

Usage

Backup:

Simply upload myphp-backup.php script to the DocumentRoot directory of your web application via FTP or other method and run it accessing http://www.example.com/myphp-backup.php. You can also run it from command line.

Don’t forget to set your database access credentials before performing any backup editing these lines from myphp-backup.php script:

/**
 * Define database parameters here
 */
define("DB_USER", 'your_username');
define("DB_PASSWORD", 'your_password');
define("DB_NAME", 'your_db_name');
define("DB_HOST", 'localhost');

define("BACKUP_DIR", 'myphp-backup-files'); // Comment this line to use same script's directory ('.')
define("TABLES", '*'); // Full backup
//define("TABLES", 'table1, table2, table3'); // Partial backup
define("CHARSET", 'utf8');
define("GZIP_BACKUP_FILE", true); // Set to false if you want plain SQL backup files (not gzipped)

By default backup files will be called myphp-backup-{DB_NAME}-YYYYmmdd-HHMMSS.sql.gz and stored in myphp-backup-filessubdirectory. Example output backup file: myphp-backup-files/myphp-backup-daniloaz-20170828-131745.sql.gz

Restore:

Upload myphp-restore.php script to your DocumentRoot directory and your backup file to a subdirectory called myphp-backup-files. Then simply run the script accessing http://www.example.com/myphp-restore.php or from command line.

You can change the backup filename and subdirectory editing these lines. Don’t forget to set your user credentials too!

/**
 * Define database parameters here
 */
define("DB_USER", 'your_username');
define("DB_PASSWORD", 'your_password');
define("DB_NAME", 'your_db_name');
define("DB_HOST", 'localhost');
define("BACKUP_DIR", 'myphp-backup-files'); // Comment this line to use same script's directory ('.')
define("BACKUP_FILE", 'your-backup-file.sql.gz'); // Script will autodetect if backup file is gzipped or not based on .gz extension
define("CHARSET", 'utf8');

 


Yorumlar

Yazıya 1 yorum yapılmış.

Hasan CODEK Tuesday May 1st, 2018

Merhaba, güzel bir çalışma olmuş. Yedek almak için her defasında veritabanına bağlanmaya kullanıcı adı şifre girmeye gerek yok artık. Teşekkürler…

Benzer İçerikler