#!/usr/bin/perl

## no critic (CodeLayout::ProhibitParensWithBuiltins);

use strict;
use warnings;
use autodie;

use Stanford::WWWScheduler qw(dump_mysql read_config);

my $CONFIG_FILE = '/etc/www-scheduler/www-scheduler-config.yaml';
my %CONFIG      = read_config($CONFIG_FILE);

my $dumpfile = $ARGV[0];

if (!$dumpfile) {
    print "missing first argument (dump file location)\n";
    exit(1);
} elsif (-f $dumpfile) {
    unlink $dumpfile;
}

dump_mysql(\%CONFIG, $dumpfile);

exit(0);

__END__

=for stopwords Lewenberg

=head1 NAME

dump-scheduler-db - export WWW scheduler database to a file

=head1 USAGE

dump-scheduler-db I</path/to/dumpfile>

=head1 DESCRIPTION

The B<dump-scheduler-db> script exports the MySQL database to a specified
external file. This script expects to find the database configuration in
the file F</etc/www-scheduler/www-scheduler-config.yaml>.

=head1 OPTIONS

None.

=head1 BUGS AND LIMITATIONS

None known.

=head1 CONFIGURATION

Configuration is in the file
F</etc/www-scheduler/www-scheduler-config.yaml>.

=head1 AUTHOR

Adam Lewenberg <adamhl@stanford.edu>

=head1 LICENSE AND COPYRIGHT

Copyright 2022 The Board of Trustees of the Leland Stanford Junior
University.  All rights reserved.

Permission to use, copy, modify, and distribute this software and its
documentation for any purpose and without fee is hereby granted, provided
that the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting
documentation, and that the name of Stanford University not be used in
advertising or publicity pertaining to distribution of the software
without specific, written prior permission.  Stanford University makes no
representations about the suitability of this software for any purpose.
It is provided "as is" without express or implied warranty.

THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.

=cut

#############################################################################
#############################################################################
