Mysqldump using puppet

42 views
Skip to first unread message

Md Juyel Haque

unread,
Jul 31, 2020, 1:17:22 PM7/31/20
to Puppet Users
Please help me.I want to create  script database backup. This should be deployed with the puppet scripts on the Tomcat server.
Errors from the dump should be noted and an email sent to particular email address in case of errors/failure.
The script should also take the IP addresses from the Cloudformation template specified and SCP the backup to each of these servers.

Chris

unread,
Jul 31, 2020, 4:09:10 PM7/31/20
to puppet...@googlegroups.com
I use this as my mysql backup script:  https://github.com/ghstwhl/MySQLBackup

It expects that the credentials for the database are in ~/.my.cnf for the user running the script.  If you are using puppetlabs/mysql to manage your mysql database then this is already set up for you and you just need to run your cron job as root.  Right now it assumes it is running on the DB server itself, but the ParseMyCnf function could be easily tweaked to read the server address from ~/.my.cnf if it exists and only default to localhost if a host isn't specified.

It doesn't currently send emails on errors, but you can fork the repo and submit a PR and I'd be happy to merge.


-Chris

--
You received this message because you are subscribed to the Google Groups "Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/74ab9a41-6043-42db-8e25-68ec2adaa998o%40googlegroups.com.

Md Juyel Haque

unread,
Jul 31, 2020, 5:31:28 PM7/31/20
to puppet...@googlegroups.com
if I write this code how will I run it from puppet



--

Thanks & Regards,
Md Juyel Haque | Sr. DevOps Engineer 
Phone No: 7047906982 

Chris

unread,
Jul 31, 2020, 5:47:50 PM7/31/20
to puppet...@googlegroups.com
You put the perl script and backup scripts in a module, and deploy as files.  In my case, they are part of a private module called bayhosting:

file {
    "/var/local/backups/mysql":
      ensure  => directory,
      mode  =>  '0700',
      owner  =>  'root',
      group  =>  'root',
      require => File['/var/local/backups'];

    "/opt/bin/MySQLBackup.pl":
      source => "puppet:///modules/bayhosting/opt/bin/MySQLBackup.pl",
      owner   => 'root',
      group   => 'root',
      mode    => '0555';

    "/root/backup.sh":
      source => "puppet:///modules/bayhosting/root/backup.sh",
      owner   => 'root',
      group   => 'root',
      mode    => '0555';
 }

And then you set up a cron job:

cron {
    cron_mysqlbackup:
      command  =>  "/root/backup.sh",
      user  =>  root,
      hour  => 0,
      minute  => 0,
      require => File['/opt/bin/MySQLBackup.pl',"/var/local/backups/mysql", "/root/backup.sh"];
}


Md Juyel Haque

unread,
Jul 31, 2020, 6:09:12 PM7/31/20
to puppet...@googlegroups.com

Md Juyel Haque

unread,
Aug 2, 2020, 9:30:41 AM8/2/20
to puppet...@googlegroups.com
Hi y tickets are these
I am struggling with to write scripts

another two scripts I need please 
1 )
In the Puppet scripts, create a script which is active on every environment except for prod and is only installed on the SSH servers. This script should run via cron every 5 minutes, which can be installed via Puppet (see common::cronjob).  

2) Create a script in Puppet which is installed in the Tomcat servers only for non-production environments and is not available in production and runs via cron every 5 minutes. The script will install the DB backup when it is found in the IAM user’s directory  




Michael Watters

unread,
Aug 3, 2020, 10:31:49 AM8/3/20
to Puppet Users

Why do these feel like homework questions?  :D


You can add logic to your manifest  based on what environment the agent is running under using simple if statements.  For example:


if $facts['environment'] != 'production' {

    notify { 'This is a non-production node!': }

}


If you're not familiar with writing puppet manifests the Puppet Learning VM would be a good place to start.


https://puppet.com/try-puppet/puppet-learning-vm/

okay Thank You 

To unsubscribe from this group and stop receiving emails from it, send an email to puppet...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to puppet...@googlegroups.com.


--

Thanks & Regards,
Md Juyel Haque | Sr. DevOps Engineer 
Phone No: 7047906982 

--
You received this message because you are subscribed to the Google Groups "Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to puppet...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to puppet...@googlegroups.com.


--

Thanks & Regards,
Md Juyel Haque | Sr. DevOps Engineer 
Phone No: 7047906982 
Reply all
Reply to author
Forward
0 new messages