Compare commits
3 Commits
Author | SHA1 | Date | |
---|---|---|---|
eb8bdde1fc
|
|||
5d17aaf03a
|
|||
d181d2970f
|
5
PKGBUILD
5
PKGBUILD
@ -14,7 +14,8 @@ makedepends=('git')
|
|||||||
depends=('python3'
|
depends=('python3'
|
||||||
'rsync'
|
'rsync'
|
||||||
'python-dotenv'
|
'python-dotenv'
|
||||||
'python-dbus')
|
'python-dbus'
|
||||||
|
'python-systemd')
|
||||||
install=${pkgname}.install
|
install=${pkgname}.install
|
||||||
source=(git+https://github.com/Fuxino/${pkgname}.git)
|
source=(git+https://github.com/Fuxino/${pkgname}.git)
|
||||||
sha256sums=('SKIP')
|
sha256sums=('SKIP')
|
||||||
@ -28,5 +29,5 @@ pkgver()
|
|||||||
package()
|
package()
|
||||||
{
|
{
|
||||||
install -Dm755 "${srcdir}/${pkgname}/${pkgname}.py" "${pkgdir}/usr/bin/${pkgname}"
|
install -Dm755 "${srcdir}/${pkgname}/${pkgname}.py" "${pkgdir}/usr/bin/${pkgname}"
|
||||||
install -Dm644 "${srcdir}/${pkgname}/${pkgname}.config" "${pkgdir}/etc/${pkgname}/${pkgname}.config"
|
install -Dm644 "${srcdir}/${pkgname}/${pkgname}.config" "${pkgdir}/etc/${pkgname}/${pkgname}.conf"
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
post_install() {
|
post_install() {
|
||||||
echo "An example configuration file is found in /etc/simple_backup/simple_backup.config."
|
echo "An example configuration file is found in /etc/simple_backup/simple_backup.conf."
|
||||||
echo "Copy it to ~/config/simple_backup/simple_backup.config and modify it as needed"
|
echo "Copy it to ~/config/simple_backup/simple_backup.conf and modify it as needed"
|
||||||
}
|
}
|
||||||
|
|
||||||
post_upgrade() {
|
post_upgrade() {
|
||||||
|
@ -103,11 +103,18 @@ class Backup:
|
|||||||
logger.warning(f'Input {i} is a link and cannot be read. Skipping')
|
logger.warning(f'Input {i} is a link and cannot be read. Skipping')
|
||||||
self.inputs.remove(i)
|
self.inputs.remove(i)
|
||||||
|
|
||||||
|
if self.output is None:
|
||||||
|
logger.critical('No output path specified. Use -o argument or specify output path in configuration file')
|
||||||
|
|
||||||
|
return False
|
||||||
|
|
||||||
if not os.path.isdir(self.output):
|
if not os.path.isdir(self.output):
|
||||||
logger.critical('Output path for backup does not exist')
|
logger.critical('Output path for backup does not exist')
|
||||||
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
self.output = os.path.abspath(self.output)
|
||||||
|
|
||||||
if self.keep is None:
|
if self.keep is None:
|
||||||
self.keep = -1
|
self.keep = -1
|
||||||
|
|
||||||
@ -236,11 +243,11 @@ class Backup:
|
|||||||
|
|
||||||
def _parse_arguments():
|
def _parse_arguments():
|
||||||
parser = argparse.ArgumentParser(prog='simple_backup',
|
parser = argparse.ArgumentParser(prog='simple_backup',
|
||||||
description='A simple backup script written in Python that uses rsync to copy files',
|
description='Simple backup script written in Python that uses rsync to copy files',
|
||||||
epilog='Report bugs to dfucini<at>gmail<dot>com',
|
epilog='Report bugs to dfucini<at>gmail<dot>com',
|
||||||
formatter_class=MyFormatter)
|
formatter_class=MyFormatter)
|
||||||
|
|
||||||
parser.add_argument('-c', '--config', default=f'{homedir}/.config/simple_backup/simple_backup.config',
|
parser.add_argument('-c', '--config', default=f'{homedir}/.config/simple_backup/simple_backup.conf',
|
||||||
help='Specify location of configuration file')
|
help='Specify location of configuration file')
|
||||||
parser.add_argument('-i', '--input', nargs='+', help='Paths/files to backup')
|
parser.add_argument('-i', '--input', nargs='+', help='Paths/files to backup')
|
||||||
parser.add_argument('-o', '--output', help='Output directory for the backup')
|
parser.add_argument('-o', '--output', help='Output directory for the backup')
|
||||||
@ -294,8 +301,6 @@ def simple_backup():
|
|||||||
else:
|
else:
|
||||||
backup_options = '-arvh -H -X'
|
backup_options = '-arvh -H -X'
|
||||||
|
|
||||||
output = os.path.abspath(output)
|
|
||||||
|
|
||||||
backup = Backup(inputs, output, exclude, keep, backup_options)
|
backup = Backup(inputs, output, exclude, keep, backup_options)
|
||||||
|
|
||||||
if backup.check_params():
|
if backup.check_params():
|
||||||
@ -304,17 +309,20 @@ def simple_backup():
|
|||||||
obj = dbus.Interface(obj, "org.freedesktop.Notifications")
|
obj = dbus.Interface(obj, "org.freedesktop.Notifications")
|
||||||
obj.Notify("simple_backup", 0, "", "Starting backup...", "", [], {"urgency": 1}, 10000)
|
obj.Notify("simple_backup", 0, "", "Starting backup...", "", [], {"urgency": 1}, 10000)
|
||||||
except dbus.exceptions.DBusException:
|
except dbus.exceptions.DBusException:
|
||||||
pass
|
obj = None
|
||||||
|
|
||||||
status = backup.run()
|
status = backup.run()
|
||||||
|
|
||||||
try:
|
if obj is not None:
|
||||||
if status == 0:
|
if status == 0:
|
||||||
obj.Notify("simple_backup", 0, "", "Backup finished.", "", [], {"urgency": 1}, 10000)
|
obj.Notify("simple_backup", 0, "", "Backup finished.", "", [], {"urgency": 1}, 10000)
|
||||||
else:
|
else:
|
||||||
obj.Notify("simple_backup", 0, "", "Backup finished. Some errors occurred.", "", [], {"urgency": 1}, 10000)
|
obj.Notify("simple_backup", 0, "", "Backup finished. Some errors occurred.",
|
||||||
except NameError:
|
"", [], {"urgency": 1}, 10000)
|
||||||
pass
|
|
||||||
|
return 0
|
||||||
|
|
||||||
|
return 1
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
Reference in New Issue
Block a user