Skip to content

Instantly share code, notes, and snippets.

@flaviu-chelaru
Last active October 1, 2019 06:55
Show Gist options
  • Save flaviu-chelaru/47c7c6dc163d80574f4039be135e0996 to your computer and use it in GitHub Desktop.
Save flaviu-chelaru/47c7c6dc163d80574f4039be135e0996 to your computer and use it in GitHub Desktop.

Backup crons

These can be used to setup backups in a shared hosting with CPANEL (for example)

Backup a public web directory to a ftp directory

cd ~/public_html && tar -zcvf ~/public_ftp/bkp$(date +\%F).tar.gz .

Dump a database to a ftp directory

mysqldump -u<user> -p'<pass>' <dbname> > ~/public_ftp/dump-$(date +\%F).sql

Remove files older than 14 days

find ~/public_ftp -mtime +13 -type f -delete
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment