Skip to content

Take backups of your mysql/mariadb databases and your files/folders. This bash script can be useful for linux server backups or migrations.

License

Notifications You must be signed in to change notification settings

spithash/Linux-Backup-Script

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 

Repository files navigation

Linux Backup Script (Bash)

Take backups of your mysql/mariadb databases and your files/folders. This can be useful for server backups or migrations. I personaly use it to backup all of /etc/ and maybe home user directories including websites and databases that I maintain.
Makes my life easier not having to go through all the progress again and again. I just change the folder paths to the ones I need and I'm ready to go. The script will use gzip to create .gz archives of your files.

Requirements

Packages pv & gzip are required to be installed on your system because they're needed for the progress bar and archive creation of your files and .sql databases. Use your favourite package manager and install them. On Debian this should do: sudo apt install pv gzip
Also, sudo is required. We need it so we can backup system files.

MySQL/MariaDB

The script will ask for mysql user and password confirmation each time you dump a database. If this bothers you, then you should create a .my.cnf file (see below) and also you should remove "-u root -p" from the mysql commands to avoid trying to connect as root if you don't have to.

.my.cnf – mysql user & password

Create file ~/.my.cnf and add following lines in it and replace mysqluser & mysqlpass values.

[client]
user=mysqluser
password=mysqlpass

For safety, make this file readable to you only by running chmod 0600 ~/.my.cnf

Usage

Just run it with: sudo bash fullsysbackup.sh

TODO:

  • Make it work with dialog for a fancy progress bar.
  • Maybe use rsync to copy files to a remote machine?

About

Take backups of your mysql/mariadb databases and your files/folders. This bash script can be useful for linux server backups or migrations.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages