Compare commits
8 Commits
Author | SHA1 | Date | |
---|---|---|---|
97419c30f9
|
|||
c6871ac81a
|
|||
90120031e2
|
|||
d61ffa199a
|
|||
a4c4b88193
|
|||
eb8bdde1fc
|
|||
5d17aaf03a
|
|||
d181d2970f
|
38
PKGBUILD
38
PKGBUILD
@ -1,32 +1,48 @@
|
||||
#Arch Linux PKGBUILD
|
||||
#
|
||||
#Maintainer: Daniele Fucini <dfucini@gmail.com>
|
||||
#
|
||||
# PKGBUILD
|
||||
|
||||
# Maintainer: Daniele Fucini <dfucini@gmail.com>
|
||||
|
||||
pkgname=simple_backup
|
||||
pkgver=2.0.0.r3.gc61c704
|
||||
pkgver=3.1.2.r1.ga4c4b88
|
||||
pkgrel=1
|
||||
pkgdesc='Simple backup script that uses rsync to copy files'
|
||||
arch=('any')
|
||||
url="https://github.com/Fuxino/simple_backup.git"
|
||||
license=('GPL3')
|
||||
makedepends=('git')
|
||||
depends=('python3'
|
||||
makedepends=('git'
|
||||
'python-setuptools'
|
||||
'python-build'
|
||||
'python-installer'
|
||||
'python-wheel')
|
||||
depends=('python'
|
||||
'rsync'
|
||||
'python-dotenv'
|
||||
'python-dbus')
|
||||
'python-dbus'
|
||||
'python-systemd')
|
||||
install=${pkgname}.install
|
||||
source=(git+https://github.com/Fuxino/${pkgname}.git)
|
||||
sha256sums=('SKIP')
|
||||
|
||||
pkgver()
|
||||
{
|
||||
cd "$pkgname"
|
||||
cd ${pkgname}
|
||||
git describe --long --tags | sed 's/\([^-]*-g\)/r\1/;s/-/./g'
|
||||
}
|
||||
|
||||
prepare()
|
||||
{
|
||||
git -C ${srcdir}/${pkgname} clean -dfx
|
||||
}
|
||||
|
||||
build()
|
||||
{
|
||||
cd ${srcdir}/${pkgname}
|
||||
python -m build --wheel --no-isolation
|
||||
}
|
||||
|
||||
package()
|
||||
{
|
||||
install -Dm755 "${srcdir}/${pkgname}/${pkgname}.py" "${pkgdir}/usr/bin/${pkgname}"
|
||||
install -Dm644 "${srcdir}/${pkgname}/${pkgname}.config" "${pkgdir}/etc/${pkgname}/${pkgname}.config"
|
||||
cd ${srcdir}/${pkgname}
|
||||
python -m installer --destdir=${pkgdir} dist/*.whl
|
||||
install -Dm644 ${srcdir}/${pkgname}/${pkgname}.conf ${pkgdir}/etc/${pkgname}/${pkgname}.conf
|
||||
}
|
||||
|
35
README.md
35
README.md
@ -1,10 +1,37 @@
|
||||
# simple_backup
|
||||
simple_backup
|
||||
============
|
||||
A simple backup script
|
||||
|
||||
## Description
|
||||
simple_backup is a Python script that allows you to backup your files.
|
||||
It reads from a configuration file the files/directories that must be copied,
|
||||
the destination directory for the backup and a few other options.
|
||||
Parameters like input files/directories, output directory etc. can be specified in a configuration file, or on the command line. Run:
|
||||
|
||||
```bash
|
||||
simple_backup -h
|
||||
```
|
||||
|
||||
to print all possible command line options.
|
||||
|
||||
## Dependencies
|
||||
rsync is used to perform the backup.
|
||||
The script uses rsync to actually run the backup, so you will have to install it on your system. For example on Arch Linux:
|
||||
|
||||
```bash
|
||||
sudo pacman -Syu rsync
|
||||
```
|
||||
|
||||
## Install
|
||||
To install the program, first clone the repository:
|
||||
|
||||
```bash
|
||||
git clone https://github.com/Fuxino/simple_backup.git
|
||||
```
|
||||
|
||||
Then run:
|
||||
|
||||
```bash
|
||||
cd simple_backup
|
||||
python -m build --wheel
|
||||
python -m installer dist/*.whl
|
||||
|
||||
For Arch Linux, a PKGBUILD that automates this process is provided.
|
||||
|
||||
|
3
pyproject.toml
Normal file
3
pyproject.toml
Normal file
@ -0,0 +1,3 @@
|
||||
[build-system]
|
||||
requires = ['setuptools']
|
||||
build-backend = 'setuptools.build_meta'
|
@ -1 +0,0 @@
|
||||
python-dotenv>=1.0.0
|
35
setup.cfg
Normal file
35
setup.cfg
Normal file
@ -0,0 +1,35 @@
|
||||
[metadata]
|
||||
name = simple_backup
|
||||
version = attr: simple_backup.__version__
|
||||
description = Simple backup script using rsync
|
||||
long_description = file: README.md
|
||||
author = Daniele Fucini
|
||||
author_email = dfucini@gmail.com
|
||||
license = GPL3
|
||||
url = https://github.com/Fuxino/simple_backup
|
||||
classifiers =
|
||||
Development Status :: 5 - Production/Stable
|
||||
Environment :: Console
|
||||
License :: OSI Approved :: GNU General Public License v3 (GPLv3)
|
||||
Natural Language :: English
|
||||
Operating System :: POSIX :: Linux
|
||||
Programming Language :: Python :: 3.7
|
||||
Programming Language :: Python :: 3.8
|
||||
Programming Language :: Python :: 3.9
|
||||
Programming Language :: Python :: 3.10
|
||||
Programming Language :: Python :: 3.11
|
||||
Topic :: System :: Archiving :: Backup
|
||||
|
||||
[options]
|
||||
packages = simple_backup
|
||||
python_requires = >=3.7
|
||||
install_requires =
|
||||
python-dotenv
|
||||
systemd-python
|
||||
|
||||
[options.entry_points]
|
||||
console_scripts =
|
||||
simple_backup = simple_backup:simple_backup
|
||||
|
||||
[options.data_files]
|
||||
../etc/simple_backup = simple_backup/simple_backup.conf
|
@ -1,6 +1,6 @@
|
||||
post_install() {
|
||||
echo "An example configuration file is found in /etc/simple_backup/simple_backup.config."
|
||||
echo "Copy it to ~/config/simple_backup/simple_backup.config and modify it as needed"
|
||||
echo "An example configuration file is found in /etc/simple_backup/simple_backup.conf."
|
||||
echo "Copy it to ~/config/simple_backup/simple_backup.conf and modify it as needed"
|
||||
}
|
||||
|
||||
post_upgrade() {
|
||||
|
3
simple_backup/__init__.py
Normal file
3
simple_backup/__init__.py
Normal file
@ -0,0 +1,3 @@
|
||||
"""Init."""
|
||||
|
||||
__version__ = '3.1.2'
|
14
simple_backup/simple_backup.conf
Normal file
14
simple_backup/simple_backup.conf
Normal file
@ -0,0 +1,14 @@
|
||||
#Example config file for simple_backup
|
||||
|
||||
[default]
|
||||
#Input directories. Use a comma to separate items
|
||||
inputs=/home/my_home,/etc
|
||||
|
||||
#Output directory
|
||||
backup_dir=/media/Backup
|
||||
|
||||
#Exclude patterns. Use a comma to separate items
|
||||
exclude=.gvfs,.local/share/gvfs-metadata,.cache,.dbus,.Trash,.local/share/Trash,.macromedia,.adobe,.recently-used,.recently-used.xbel,.thumbnails
|
||||
|
||||
#Number of snapshots to keep (use -1 to keep all)
|
||||
keep=-1
|
@ -103,11 +103,18 @@ class Backup:
|
||||
logger.warning(f'Input {i} is a link and cannot be read. Skipping')
|
||||
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):
|
||||
logger.critical('Output path for backup does not exist')
|
||||
|
||||
return False
|
||||
|
||||
self.output = os.path.abspath(self.output)
|
||||
|
||||
if self.keep is None:
|
||||
self.keep = -1
|
||||
|
||||
@ -236,11 +243,11 @@ class Backup:
|
||||
|
||||
def _parse_arguments():
|
||||
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',
|
||||
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')
|
||||
parser.add_argument('-i', '--input', nargs='+', help='Paths/files to backup')
|
||||
parser.add_argument('-o', '--output', help='Output directory for the backup')
|
||||
@ -294,8 +301,6 @@ def simple_backup():
|
||||
else:
|
||||
backup_options = '-arvh -H -X'
|
||||
|
||||
output = os.path.abspath(output)
|
||||
|
||||
backup = Backup(inputs, output, exclude, keep, backup_options)
|
||||
|
||||
if backup.check_params():
|
||||
@ -304,17 +309,20 @@ def simple_backup():
|
||||
obj = dbus.Interface(obj, "org.freedesktop.Notifications")
|
||||
obj.Notify("simple_backup", 0, "", "Starting backup...", "", [], {"urgency": 1}, 10000)
|
||||
except dbus.exceptions.DBusException:
|
||||
pass
|
||||
obj = None
|
||||
|
||||
status = backup.run()
|
||||
|
||||
try:
|
||||
if obj is not None:
|
||||
if status == 0:
|
||||
obj.Notify("simple_backup", 0, "", "Backup finished.", "", [], {"urgency": 1}, 10000)
|
||||
else:
|
||||
obj.Notify("simple_backup", 0, "", "Backup finished. Some errors occurred.", "", [], {"urgency": 1}, 10000)
|
||||
except NameError:
|
||||
pass
|
||||
obj.Notify("simple_backup", 0, "", "Backup finished. Some errors occurred.",
|
||||
"", [], {"urgency": 1}, 10000)
|
||||
|
||||
return 0
|
||||
|
||||
return 1
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
Reference in New Issue
Block a user