Last updated on February 21st, 2022 at 06:54 pm
MySql database backup compress in single command.
This is a simple and quick tutorial on how to take mysql database backup and compress the backup sql file in a single command.
This is how it looks
mysqldump -u <user_name> -p<password> <database_name>|gzip > "<directory_to_copy_the_compressed_file>/<file_name>"
For example let us say USER_NAME=root, PASSWORD=root, DATABASE_NAME=mydata, DIRECTORY_TO_COPY_THE_COMPRESSED_FILE=/tmp/databasebackup & FILE_NAME=mydata.sql.gz
Then the command will look like this
mysqldump -u root -proot > mydata|gzip > "/tmp/databasebackup/mydata.sql.gz"
Hope this helps you to take mysql backups at least once every month .