• About Us
  • Privacy & Policy
HowTo's
  • Home
  • Commands
  • Linux
  • SCM
  • Git
  • Database
  • MySQL
  • Kubernetes
  • Docker
No Result
View All Result
  • Home
  • Commands
  • Linux
  • SCM
  • Git
  • Database
  • MySQL
  • Kubernetes
  • Docker
No Result
View All Result
HowTo's
No Result
View All Result
Home Database

Adding Dump Date to mysqldump Output

June 22, 2024
in Database, Database Commands Examples, Database Commands Tutorial, Database Tutorial, MySQL, MySQL Commands, MySQL Commands Examples, MySQL Tutorial
A A
0
11
SHARES
103
VIEWS
Share on FacebookShare on Twitter

The mysqldump command is used to create backups of MySQL databases. One useful option is --dump-date, which adds the dump date to the output filename, providing a timestamped version of the backup.

Here are several examples demonstrating the use of --dump-date:

Example 1: Adding a date suffix to the backup file.

    mysqldump --dump-date mydatabase > mydatabase_$(date +%F).sql
    

This command dumps the database mydatabase to a file named mydatabase_YYYY-MM-DD.sql, where YYYY-MM-DD represents the current date.

Example 2: Using a custom format for the date.

    mysqldump --dump-date=mydatabase > mydatabase_$(date +%Y%m%d%H%M%S).sql
    

Here, the output filename will include a timestamp in the format YYYYMMDDHHMMSS.

Example 3: Dumping multiple databases with date suffixes.

    mysqldump --dump-date database1 database2 > databases_$(date +%Y-%m-%d).sql
    

This command dumps both database1 and database2 to a single file named databases_YYYY-MM-DD.sql.

Example 4: Appending the date to an existing backup file.

    mysqldump --dump-date --append mydatabase >> mydatabase_backup.sql
    

Using --append adds the dump of mydatabase to an existing file named mydatabase_backup.sql with a new timestamped section.

Example 5: Creating a gzipped backup file with date.

    mysqldump --dump-date mydatabase | gzip > mydatabase_$(date +%Y-%m-%d).sql.gz
    

This command creates a compressed backup file named mydatabase_YYYY-MM-DD.sql.gz.

To verify whether these commands executed successfully, check the existence and timestamp of the output files using:

    ls -l mydatabase_*
    

Replace mydatabase_* with the actual filename pattern used in your command to see if the file was created with the expected date suffix.

Also check similar articles.

Creating Consistent Snapshot with Single Transaction in mysqldump
Adding GTID_PURGED to mysqldump Output
Setting Character Set in mysqldump Output
Dumping Routines (Functions and Procedures) with mysqldump
Directing Output to File in mysqldump

Tags: DatabaseDatabase Commands ExamplesDatabase Commands TutorialDatabase TutorialMySQLMySQL CommandsMySQL Commands ExamplesMySQL Tutorial
Previous Post

Creating Consistent Snapshot with Single Transaction in mysqldump

Next Post

Disabling Optimization Options in mysqldump

Related You may like!

howto

Overriding –databases Option in mysqldump

June 22, 2024
howto

Creating Tab-Separated Output Files with mysqldump

June 22, 2024

Handling Failed SSL Session Data Reuse in mysqldump

June 22, 2024

Setting SSL Session Data File in mysqldump

June 22, 2024

Setting TLS 1.3 Cipher in mysqldump

June 22, 2024

Configuring SSL FIPS Mode in mysqldump (OpenSSL Only)

June 22, 2024
Next Post
howto

Disabling Optimization Options in mysqldump

howto

Setting Server Public Key Path in mysqldump

howto

Retrieving Server Public Key in mysqldump

Discussion about this post

Latest Updated

howto

How to Use -iname for Case-Insensitive Filename Searches in find

August 21, 2024
howto

Search for Files with Case-Insensitive Pattern Matching Using -ilname in find

August 21, 2024
howto

Find Files by Group Name with -group in find Command

August 21, 2024
howto

Locate Files by Group ID Using -gid in find Command

August 21, 2024
howto

How to Search for Filesystems with -fstype in find Command

August 21, 2024

Trending in Week

  • howto

    Dumping BLOBs in Hexadecimal Format with mysqldump

    16 shares
    Share 6 Tweet 4
  • How to Exclude Bad Names when Creating User Accounts in Linux

    14 shares
    Share 6 Tweet 4
  • Using BTRFS Subvolume for User Home Directory in Linux

    24 shares
    Share 10 Tweet 6
  • Managing Kubernetes Certificates with kubectl certificate

    20 shares
    Share 8 Tweet 5
  • Running Docker Images on Kubernetes with kubectl run

    13 shares
    Share 5 Tweet 3
  • Disabling Keys in mysqldump Output

    12 shares
    Share 5 Tweet 3
  • Managing Docker Image Manifests and Lists

    12 shares
    Share 5 Tweet 3
  • Adding Dump Date to mysqldump Output

    11 shares
    Share 4 Tweet 3
  • Updating Kubernetes Labels with kubectl label

    12 shares
    Share 5 Tweet 3
  • Sorting Rows by Primary Key in mysqldump Output

    12 shares
    Share 5 Tweet 3
  • About Us
  • Privacy & Policy

© 2024 All Rights Reserved. Howto.swebtools.com.

No Result
View All Result

© 2024 All Rights Reserved. Howto.swebtools.com.