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"];
}

On Sat, Aug 1, 2020 at 9:31 AM Md Juyel Haque <haquemohammedju...@gmail.com>
wrote:

> if I write this code how will I run it from puppet
>
> On Sat, Aug 1, 2020 at 1:39 AM Chris <boh...@gmail.com> wrote:
>
>> 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
>>
>> On Sat, Aug 1, 2020 at 5:17 AM Md Juyel Haque <
>> haquemohammedju...@gmail.com> wrote:
>>
>>> 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.
>>>
>>> --
>>> 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+unsubscr...@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
>>> <https://groups.google.com/d/msgid/puppet-users/74ab9a41-6043-42db-8e25-68ec2adaa998o%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>>
>> --
>> 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+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/puppet-users/CAABnqB8rJDhgQFUrmGsnLTOuj6h15Q9ZaDjzBC%2BHJR%3DRi-8iLQ%40mail.gmail.com
>> <https://groups.google.com/d/msgid/puppet-users/CAABnqB8rJDhgQFUrmGsnLTOuj6h15Q9ZaDjzBC%2BHJR%3DRi-8iLQ%40mail.gmail.com?utm_medium=email&utm_source=footer>
>> .
>>
>
>
> --
>
> Thanks & Regards,
> Md Juyel Haque | Sr. DevOps Engineer
> Phone No: 7047906982
> Email: haquemohammedju...@gmail.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-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/puppet-users/CAH_OGbb0g3aZkoQ%2BRvcph5am_JbER73H3sXwCz%2BS%2BW3k%3Dj_%2BFQ%40mail.gmail.com
> <https://groups.google.com/d/msgid/puppet-users/CAH_OGbb0g3aZkoQ%2BRvcph5am_JbER73H3sXwCz%2BS%2BW3k%3Dj_%2BFQ%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/CAABnqB-H3dhEx2bf0rL0iLgXSzqf0oi9prij_6S93bZqDO6D8g%40mail.gmail.com.

Reply via email to