| 1 | #!/usr/bin/perl | ||
| 2 | |||
| 3 | use oEdtk::Config qw(config_read); | ||
| 4 | use oEdtk::DBAdmin qw(db_connect historicize_table); | ||
| 5 | use Term::ReadKey; | ||
| 6 | use POSIX qw(strftime); | ||
| 7 | use warnings; | ||
| 8 | use strict; | ||
| 9 | |||
| 10 | my $cfg = config_read('EDTK_DB'); | ||
| 11 | my $dbh = db_connect( $cfg, 'EDTK_DBI_DSN' ); | ||
| 12 | my $suffixe = strftime "%Y%m%d%H%M%S", localtime; | ||
| 13 | my $wait_time = 30 * $cfg->{'EDTK_WAITRUN'} || 600; | ||
| 14 | |||
| 15 | warn "INFO: historicize tracking table\n"; | ||
| 16 | warn "INFO: table should not be in use\n"; | ||
| 17 | warn "INFO: waiting $wait_time sec... press 'N' or 'S' to stop or any to run\n"; | ||
| 18 | |||
| 19 | ReadMode('raw'); | ||
| 20 | my $key = ReadKey($wait_time); | ||
| 21 | if ( $key =~ /^[ns]$/i ) { | ||
| 22 | die "INFO: abort request\n"; | ||
| 23 | } | ||
| 24 | ReadMode('restore'); | ||
| 25 | |||
| 26 | historicize_table( $dbh, $cfg->{'EDTK_DBI_TRACKING'}, $suffixe ); | ||
| 27 | |||
| 28 | warn "INFO: backup done for " . $cfg->{'EDTK_DBI_TRACKING'} . "\n"; |