Build a ready-to-use mysqldump backup script for MySQL/MariaDB — gzip compression, retention cleanup, optional rsync remote transfer, timestamped filenames and cron schedule presets.
MySQL/MariaDB용 mysqldump 백업 스크립트를 즉시 생성 — gzip 압축, 보관 기간 자동 정리, rsync 원격 전송, 타임스탬프 파일명, 크론 스케줄 프리셋 지원.
Database
Backup Options
Remote Transfer (optional)
Cron Schedule
How to Use
STEP 1
Enter the database name, MySQL user, and where backups should be stored. Keep gzip and timestamped filenames on for smaller, non-overwriting backups.
STEP 2
Enable rsync transfer and enter a user@host and remote path so backups leave the VPS — critical for real disaster recovery.
STEP 3
Click a preset — daily 2 AM, every 6 hours, or weekly Sunday 3 AM — or type your own crontab expression.
STEP 4
Copy or download backup.sh, follow the install instructions to save it as /usr/local/bin/backup-db.sh, chmod +x, and add the generated crontab line.
사용 방법
STEP 1
데이터베이스 이름, MySQL 사용자, 백업 저장 위치를 입력하세요. gzip 압축과 타임스탬프 파일명을 켜두면 더 작고 덮어쓰지 않는 백업을 얻을 수 있습니다.
STEP 2
rsync 전송을 켜고 user@host와 원격 경로를 입력하면 백업이 VPS 밖으로 전송됩니다 — 실제 재해 복구에 필수입니다.
STEP 3
프리셋(매일 새벽 2시, 매 6시간, 매주 일요일 새벽 3시)을 클릭하거나 직접 crontab 표현식을 입력하세요.
STEP 4
backup.sh를 복사·다운로드한 뒤, 설치 안내에 따라 /usr/local/bin/backup-db.sh로 저장, chmod +x, 생성된 crontab 라인을 등록하세요.
Frequently Asked Questions
~/.my.cnf file with a [client] section containing user and password, then run chmod 600 ~/.my.cnf so only that account can read it — mysqldump picks up these credentials automatically. An alternative is a dedicated backup MySQL user with SELECT, LOCK TABLES and SHOW VIEW privileges only, further limiting the damage if credentials ever leak.gunzip -c backup_file.sql.gz | mysql -u root -p database_name to decompress and pipe the SQL directly into the target database. For an uncompressed .sql file, use mysql -u root -p database_name < backup_file.sql instead. Always restore into a freshly created or empty database first when testing, and confirm the dump completed successfully (no truncated file) before relying on it — periodically test-restoring backups is the only way to know they actually work.find -mtime, so remote or object-storage copies can follow a separate, longer retention policy.mydumper is a drop-in alternative that dumps tables in parallel across multiple threads, cutting backup time significantly. For very large or high-write databases, physical/hot backup tools like Percona XtraBackup (MySQL/MariaDB) copy the underlying data files directly with minimal locking, and cloud-VPS snapshot features (LVM or provider-level disk snapshots) can capture a consistent point-in-time image almost instantly. mysqldump remains the simplest and most portable option for small-to-medium databases where a few minutes of extra load is acceptable.자주 묻는 질문
~/.my.cnf 파일에 [client] 섹션으로 user와 password를 넣고 chmod 600 ~/.my.cnf로 권한을 제한하면 mysqldump가 자동으로 이 값을 읽습니다. SELECT, LOCK TABLES, SHOW VIEW 권한만 가진 전용 백업 계정을 쓰면 자격증명이 유출되어도 피해를 줄일 수 있습니다.gunzip -c backup_file.sql.gz | mysql -u root -p database_name로 압축을 풀며 바로 대상 DB에 주입할 수 있습니다. 압축하지 않은 .sql 파일은 mysql -u root -p database_name < backup_file.sql을 사용하세요. 테스트할 때는 항상 새로 만든 빈 데이터베이스에 먼저 복원하고, 덤프가 잘리지 않고 완전히 끝났는지 확인한 뒤 신뢰하세요 — 주기적으로 실제 복원 테스트를 해보는 것만이 백업이 실제로 작동하는지 아는 유일한 방법입니다.find -mtime를 통한 로컬 정리만 제어하므로, 원격이나 오브젝트 스토리지 사본은 별도의 더 긴 보관 정책을 따를 수 있습니다.mydumper는 여러 스레드로 테이블을 병렬 덤프하는 대체 도구로 백업 시간을 크게 줄여줍니다. 매우 크거나 쓰기가 많은 DB에는 Percona XtraBackup(MySQL/MariaDB) 같은 물리적·핫 백업 도구가 최소한의 잠금으로 데이터 파일을 직접 복사하며, 클라우드 VPS의 스냅샷 기능(LVM 또는 제공업체 디스크 스냅샷)은 거의 즉시 일관된 시점 이미지를 캡처할 수 있습니다. 몇 분의 추가 부하가 허용되는 중소 규모 DB에는 mysqldump가 여전히 가장 단순하고 이식성 좋은 선택입니다.