Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Shells Virtual Desktop
BMail.ag - Secure Email Service
Server.net
CPLicense.net
VPS Server
Buy VPN
Vultr
VMs for AI
HostDare
ReliableSite White-Label Dedicated Hosting for Resellers
InterServer VPS
BMail.ag - Secure Email Service
Best VPN
High-Performance Bare Metal Server Solutions
Karvl.com
Server Mania Cloud Hosting
DataWagon Hosting
AlphaVPS Hosting
Evoxt.com
Clouvider
VPS Hosting with NVMe
Residential IPs in the US & 4G Mobile Proxies in EU & US with Unlimited Bandwidth
ReliableSite White-Label Dedicated Hosting for Resellers
Rabisu - Hosting Solutions
Shells Virtual Desktop
New on LowEndTalk? Please Register and read our Community Rules.

All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.

Automating mysql backup and uploading to GDrive

aliletalilet Member

Hi,

Is there a way to automate MySQL backup and upload to GDrive.

I can do the backing up part using bash but the tricky part is to upload it on GDrive. Or shall I use PHP to do this job?

Thanks

Comments

  • You could use rclone to upload to GDrive from your bash script.

    Thanked by 2alilet raindog308
  • irmirm Member
    edited August 2017

    https://github.com/prasmussen/gdrive

    works flawlessly. i run backups with it using a cronjob/bash script (maybe not the best but it works).

    https://pastebin.com/ULeezPAf

  • WSSWSS Member
    edited August 2017

    Use ~ ~ ~ between stanzas or < p r e >

    For what it's worth, you can easily pipe the dump into gzip if you're not going to bother checking return codes, and moving/sync is kind of, well, OK, sure. Still not checking return codes.

    if [ $? -ne 0 ]; then
      OH FUCK DECIDE WHAT TO DO
    else
      OH SHIT IT WORKED.
    fi
    
  • imokimok Member

    Pastebin is not loading for me, I can't see the @irm code.

    In case it's a different one, I'm using this to backup my Confluence instance:

    #!/bin/bash
    
    # This is a script to take a MySQL dump and upload to Google Drive.
    # Uses gdrive https://github.com/prasmussen/gdrive. See the gdrive readme first.
    
    # The path to the gdrive binary
    GDRIVE_BIN=/usr/sbin/gdrive
    
    # Use "gdrive list" to get the id of the directory where you want to upload the files
    BACKUP_DRIVE_DIR=
    
    # Set your MySQL password. You can also use a config fille https://dev.mysql.com/doc/refman/5.7/en/password-security-user.html
    MYSQL_PASS=
    
    # The directory where your data is stored
    DATA_DIR=/home/confluence
    
    # The directory where the generated backup will be stored
    BACKUP_DEST_DIR=/home/backup/confluence/`date +%Y%m%d-%H%M%S`
    
    # The database you want to backup
    DATABASE_NAME=confluence
    DATABASE_USER=confluence
    
    echo "Backup from dir: $DATA_DIR"
    echo "Backup to dir: $BACKUP_DEST_DIR"
    echo "Google Drive Directory ID: $BACKUP_DRIVE_DIR"
    
    rm -rf $DATA_DIR/temp/*
    mkdir -p $BACKUP_DEST_DIR
    
    mysqldump -u $DATABASE_USER -p"$MYSQL_PASS" $DATABASE_NAME | gzip > $BACKUP_DEST_DIR/db-confluence-`date +%Y%m%d-%H%M%S`.sql.gz
    echo "MySQL backup completed"
    
    tar -cjvf $BACKUP_DEST_DIR/data-confluence-`date +%Y%m%d-%H%M%S`.bzip $DATA_DIR > $BACKUP_DEST_DIR/homedir.status
    echo "Confluence data backup completed"
    
    echo "Sending to Google Drive"
    $GDRIVE_BIN upload -r -p $BACKUP_DRIVE_DIR $BACKUP_DEST_DIR
    
    echo "Done."
    
  • jadenjaden Member
    edited August 2017

    You could use automysqlbackup and rclone.

  • bash + GDrive/rclone

  • Here's code for free backup service for your database and storage/minio
    https://github.com/negati-ve/docker-rclone-google-drive-cron-backup

  • PilzbaumPilzbaum Member
    edited October 2020

    To quote a member of this forum @codezed

    @angstrom said:
    Congrats on your first comment

    Thanked by 1angstrom
  • angstromangstrom Moderator
    edited October 2020

    @Pilzbaum said:
    To quote a member of this forum @codezed

    @angstrom said:
    Congrats on your first comment

    He's just another necro-poster trying to draw attention to something that he threw onto GitHub some hours before

    Thanked by 2lentro Pilzbaum
This discussion has been closed.