44 lines
1.2 KiB
Perl
Executable file
44 lines
1.2 KiB
Perl
Executable file
#!/usr/bin/perl
|
|
|
|
# backup_gitea_bin.pl
|
|
# Author: Tracey Clark
|
|
# Created: 2019-06-20
|
|
# You must have a mail transport agent installed to run this script
|
|
|
|
use strict;
|
|
use warnings;
|
|
|
|
### TEST CODE ###
|
|
my $gitea_bin='/home/tracey/tmp/testbin';
|
|
my $gitea_current_version='1';
|
|
my %binary_file = (
|
|
input => $gitea_bin,
|
|
version => $gitea_current_version,
|
|
);
|
|
my ( %opts ) = %binary_file;
|
|
my $input = $opts{input};
|
|
my $version = $opts{version};
|
|
my $gitea_bin_backup = '/home/tracey/tmp/testbin.' . $gitea_current_version . '.bz2';
|
|
|
|
### TEST CODE ###
|
|
# my ( %opts ) = %{shift()};
|
|
# my $input = $opts{input};
|
|
# my $version = $opts{version};
|
|
printf("Backing up the current binary\n");
|
|
printf("Input in backup_bin script is $input\n and version is $version\n");
|
|
|
|
|
|
# my $gitea_bin_backup = '/home/gitea/bin/gitea.' . $gitea_current_version . '.bz2';
|
|
printf("Gitea bin backup will be $gitea_bin_backup\n");
|
|
# Do this with a system call to make a compressed copy of the current binary
|
|
# bzip2 -k file.txt
|
|
# my $status = system("vi", "fred.txt");
|
|
# if (($status >>=8) != 0) {
|
|
# die "Failed to run vi";
|
|
# }
|
|
|
|
# HEREHERE how to specify output file??
|
|
my $bzip_status = system("/bin/bzip2 -k $input");
|
|
if (($bzip_status >>=8) != 0) {
|
|
die "Failed to run bzip2";
|
|
}
|