daily pastebin goal
63%
SHARE
TWEET

Untitled

a guest May 31st, 2017 46 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/bash
  2. PATH="/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin"
  3. db_host="localhost"
  4. db_user="backup"
  5. db_pass="XXXXXXXXXXXXXX"
  6. backup_dir="/var/backups/env_sync"
  7. panel_tables=( contacts:panelist_id contacts_addresses:address_id contacts_emails:email_id contacts_numbers:number_id contacts_others:panelist_id contacts_updates:timestamp excluded_single_emails:email panel_audit:panelist_id access_contacts_bridge:PANEL )
  8.  
  9. echo -n "Prepping dump location $(date)..."
  10. mkdir -p $backup_dir && chown mysql $backup_dir && find $backup_dir -type f -name "*.out" | xargs rm -fv
  11. echo "Done"
  12.  
  13. for obj in ${panel_tables[@]}
  14.   do
  15.     table=$(echo $obj | awk -F: '{print $1}')
  16.     key=$(echo $obj | awk -F: '{print $2}')
  17.     echo -n "Dumping random data for table: $table $(date)... "
  18.     sqlq="select * from $table where $key in (select $key from $table order by rand()) limit 10000 into outfile '$backup_dir/$table.out'"
  19.     mysql -h $db_host -u $db_user -p$db_pass -Bse "$sqlq" panel
  20.     echo "Done $(date)"
  21. done
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top