Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
166c9dbc47
|
||
|
|
28d1b0d0d0
|
||
|
|
cd80c941ad
|
||
|
|
29958896a2
|
||
|
|
d815b0832a
|
||
|
|
e6ac9e6cab
|
||
|
|
9298f4232c
|
||
|
|
1dca989310
|
||
|
|
9a68a8660d
|
||
|
|
73de4f8d25
|
||
|
|
baf5b07d23
|
||
|
|
8b30fefed3
|
||
|
|
2a5562d1a9
|
||
|
|
7091118663
|
||
|
|
3113e182c7
|
||
|
|
8fc3c42a5e
|
||
|
|
0671f86579
|
||
|
|
2f207efcf9
|
||
|
|
3cbca8e4d8
|
||
|
|
54880651be
|
||
|
|
793a30fad8
|
||
|
|
871dd0f49a
|
||
|
|
30e4416f8f
|
||
|
|
d0f888cbb4
|
||
|
|
7ef29cf551
|
||
|
|
4f5499eba9
|
||
|
|
fc165fccbf
|
||
|
|
d79ea56c0f
|
||
|
|
5189910131
|
||
|
|
7d4c43f8ff
|
||
|
|
ac7e6ec21b
|
||
|
|
578d992a19
|
||
|
|
e2d8897a45
|
||
|
|
dadc4b0265
|
||
|
|
7e7d11c520
|
||
|
|
22e0556b50
|
||
|
|
2b91178e94
|
||
|
|
2c2649113d
|
||
|
|
0f4a100ac7
|
||
|
|
60d83151dc
|
||
|
|
47aec456be
|
||
|
|
c715188973
|
||
|
|
57613649c2
|
||
|
|
67dbb49a67
|
||
|
|
e62a668f3e
|
||
|
|
bd8934d57f
|
||
|
|
96fe3c7813
|
||
|
|
9fdb959540
|
||
|
|
eb889beee7
|
||
|
|
2a37eb4172
|
||
|
|
45a07205a1
|
||
|
|
9390cd2de8
|
||
|
|
77661c0964
|
||
|
|
e3a970217f
|
@@ -0,0 +1,38 @@
|
|||||||
|
# PKGBUILD
|
||||||
|
|
||||||
|
# Maintainer: Daniele Fucini <dfucini [at] gmail [dot] com>
|
||||||
|
|
||||||
|
pkgname=simple_backup
|
||||||
|
pkgdesc='Simple backup script that uses rsync to copy files'
|
||||||
|
pkgver=4.2.0
|
||||||
|
pkgrel=1
|
||||||
|
url="https://git.shouldnt.work/fuxino/${pkgname}"
|
||||||
|
arch=('any')
|
||||||
|
license=('GPL-3.0-or-later')
|
||||||
|
makedepends=('git'
|
||||||
|
'python-setuptools'
|
||||||
|
'python-build'
|
||||||
|
'python-installer')
|
||||||
|
depends=('python>=3.10'
|
||||||
|
'rsync')
|
||||||
|
optdepends=('python-systemd: use systemd log'
|
||||||
|
'python-dbus: for desktop notifications'
|
||||||
|
'python-paramiko: for remote backup through ssh')
|
||||||
|
conflicts=('simple_backup-git')
|
||||||
|
source=(git+${url}?signed#tag=${pkgver})
|
||||||
|
validpgpkeys=('7E12BC1FF3B6EDB2CD8053EB981A2B2A3BBF5514')
|
||||||
|
sha256sums=('6c674f7981e3e5222594bdb735d4fb02ca2fcc829de57ea8f92ce71e679853f9')
|
||||||
|
|
||||||
|
build()
|
||||||
|
{
|
||||||
|
cd ${srcdir}/${pkgname}
|
||||||
|
python -m build --wheel --no-isolation
|
||||||
|
}
|
||||||
|
|
||||||
|
package()
|
||||||
|
{
|
||||||
|
cd ${srcdir}/${pkgname}
|
||||||
|
python -m installer --destdir=${pkgdir} dist/*.whl
|
||||||
|
install -Dm644 ${pkgname}/${pkgname}.conf ${pkgdir}/usr/share/doc/${pkgname}/${pkgname}.conf
|
||||||
|
install -Dm644 man/${pkgname}.1 ${pkgdir}/usr/share/man/man1/${pkgname}.1
|
||||||
|
}
|
||||||
@@ -20,21 +20,19 @@ The script uses rsync to actually run the backup, so you will have to install it
|
|||||||
sudo pacman -Syu rsync
|
sudo pacman -Syu rsync
|
||||||
```
|
```
|
||||||
|
|
||||||
It's also required to have python-dotenv
|
Optional dependencies are systemd-python to enable using systemd journal for logging, dbus-python for desktop notifications, and paramiko for remote backup.
|
||||||
|
|
||||||
Optional dependencies are systemd-python to enable using systemd journal for logging, and dbus-python for desktop notifications.
|
|
||||||
|
|
||||||
## Install
|
## Install
|
||||||
To install the program, first clone the repository:
|
To install the program, first clone the repository:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
git clone https://github.com/Fuxino/simple_backup.git
|
git clone https://git.shouldnt.work/fuxino/simple_backup.git
|
||||||
```
|
```
|
||||||
|
|
||||||
Then install the tools required to build the package:
|
Then install the tools required to build the package:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
pip install --upgrade build wheel
|
pip install --upgrade build
|
||||||
```
|
```
|
||||||
|
|
||||||
Finally, run:
|
Finally, run:
|
||||||
@@ -49,11 +47,16 @@ For Arch Linux and Arch-based distros, two packages are available in the AUR (au
|
|||||||
- **simple_backup** for the release version
|
- **simple_backup** for the release version
|
||||||
- **simple_backup-git** for the git version
|
- **simple_backup-git** for the git version
|
||||||
|
|
||||||
|
## Old backups
|
||||||
|
The number of old backups to keep can be set with the --keep (or -k) argument (or in the configuration file).
|
||||||
|
Old backups are only removed if rsync completes successfully, so that they are not deleted when the new backup may be incomplete.
|
||||||
|
The only rsync error that is ignored is return code 24 (source files vanished during the transfer), which is common when backing up a live system.
|
||||||
|
|
||||||
## Remote backup
|
## Remote backup
|
||||||
> **Warning**
|
> **Warning**
|
||||||
> This feature is experimental
|
> This feature is experimental
|
||||||
|
|
||||||
It's possible to use a remote server as destination for the backup. Just use the --username (or -u) and --host arguments (or set them in the configuration file).
|
It's possible to use a remote server as destination for the backup. Just use the --ssh-user and --ssh-host arguments (or set them in the configuration file).
|
||||||
For this to work, rsync must be installed on the server too.
|
For this to work, rsync must be installed on the server too.
|
||||||
|
|
||||||
### Server authentication
|
### Server authentication
|
||||||
@@ -68,4 +71,4 @@ sudo --preserve-env=SSH_AUTH_SOCK -s simple_backup [options]
|
|||||||
|
|
||||||
or by editing the sudoers file.
|
or by editing the sudoers file.
|
||||||
If SSH key authentication is not available, password authentication will be used instead.
|
If SSH key authentication is not available, password authentication will be used instead.
|
||||||
|
Check the man page for more details.
|
||||||
|
|||||||
+43
-16
@@ -1,4 +1,4 @@
|
|||||||
.TH SIMPLE_BACKUP 1 2023-06-15 SIMPLE_BACKUP 3.2.6
|
.TH SIMPLE_BACKUP 1 2026-10-08 SIMPLE_BACKUP 4.3.0
|
||||||
.SH NAME
|
.SH NAME
|
||||||
simple_backup \- Backup files and folders using rsync
|
simple_backup \- Backup files and folders using rsync
|
||||||
.SH SYNOPSIS
|
.SH SYNOPSIS
|
||||||
@@ -52,7 +52,15 @@ or to use single or double quotes around them.
|
|||||||
.B \-o, \-\-output DIR
|
.B \-o, \-\-output DIR
|
||||||
Specify the directory where the files will be copied. The program will automatically
|
Specify the directory where the files will be copied. The program will automatically
|
||||||
create a subdirectory called \(aqsimple_backup\(aq (if it does not already exist) and
|
create a subdirectory called \(aqsimple_backup\(aq (if it does not already exist) and
|
||||||
inside this directory the actual backup directory (using the current date and time).
|
inside this directory the actual backup directory (using the current date and time, for example
|
||||||
|
\(aq2026\-10\-08_17\-34\-47\(aq).
|
||||||
|
.RS
|
||||||
|
.P
|
||||||
|
Backups are best stored on a Linux filesystem (e.g. ext4 or btrfs). FAT and exFAT filesystems
|
||||||
|
are supported, but they don\(aqt support hard links, so each backup will be a full copy instead
|
||||||
|
of only storing files that changed since the previous one. File ownership and permissions are
|
||||||
|
not preserved either.
|
||||||
|
.RE
|
||||||
.TP
|
.TP
|
||||||
.B \-e, \-\-exclude FILE|DIR|PATTERN [FILE|...]]
|
.B \-e, \-\-exclude FILE|DIR|PATTERN [FILE|...]]
|
||||||
Specify files, directories or patterns to exclude from the backup. Matching files and directories
|
Specify files, directories or patterns to exclude from the backup. Matching files and directories
|
||||||
@@ -61,6 +69,10 @@ will not be copied. Multiple elements can be specified, in the same way as for t
|
|||||||
.B \-k, \-\-keep N
|
.B \-k, \-\-keep N
|
||||||
Specify how many old backups (so excluding the current one) will be kept. The default behavior
|
Specify how many old backups (so excluding the current one) will be kept. The default behavior
|
||||||
is to keep them all (same as N=\-1).
|
is to keep them all (same as N=\-1).
|
||||||
|
Old backups are only removed if rsync completes successfully, to avoid deleting them when the
|
||||||
|
new backup may be incomplete. rsync return code 24 (source files vanished during the transfer)
|
||||||
|
is treated as success, while any other error (including return code 23, partial transfer due to error)
|
||||||
|
will prevent old backups from being removed. This does not apply when using \-\-remove\-before\-backup.
|
||||||
.TP
|
.TP
|
||||||
.B \-u, \-\-user USERNAME
|
.B \-u, \-\-user USERNAME
|
||||||
Explicitly specify the user running the backup (in case it is needed for home directory expansion).
|
Explicitly specify the user running the backup (in case it is needed for home directory expansion).
|
||||||
@@ -86,6 +98,9 @@ if saving bandwith is needed.
|
|||||||
Remove old backups (if necessary) before creating the new backup. Useful to free some space
|
Remove old backups (if necessary) before creating the new backup. Useful to free some space
|
||||||
before performing the backup.
|
before performing the backup.
|
||||||
Default behavior is to remove old backups after successfully completing the backup.
|
Default behavior is to remove old backups after successfully completing the backup.
|
||||||
|
Note that if the backup fails after old backups have been removed, only the backups kept
|
||||||
|
according to \-\-keep will be left, and the new backup may be incomplete. In particular, with
|
||||||
|
\-\-keep 0 there will be no complete backup available until the next successful one.
|
||||||
.TP
|
.TP
|
||||||
.B \-\-no\-syslog
|
.B \-\-no\-syslog
|
||||||
Don't use systemd journal for logging.
|
Don't use systemd journal for logging.
|
||||||
@@ -93,19 +108,19 @@ Don't use systemd journal for logging.
|
|||||||
.B \-\-rsync\-options OPTIONS [OPTION...]
|
.B \-\-rsync\-options OPTIONS [OPTION...]
|
||||||
By default, the following rsync options are used:
|
By default, the following rsync options are used:
|
||||||
.RS
|
.RS
|
||||||
.PP
|
.P
|
||||||
\-a \-r \-v \-h \-s \-H \-X
|
\-a \-r \-v \-h \-s \-H \-X
|
||||||
.PP
|
.P
|
||||||
Using \-\-rsync\-options it is possible to manually select which options to use. Supported values are the following:
|
Using \-\-rsync\-options it is possible to manually select which options to use. Supported values are the following:
|
||||||
.PP
|
.P
|
||||||
\-a, \-l, \-p, \-t, \-g, \-o, \-c, \-h, \-D, \-H, \-X, \-s
|
\-a, \-l, \-p, \-t, \-g, \-o, \-c, \-h, \-D, \-H, \-X, \-s
|
||||||
.PP
|
.P
|
||||||
Options \-r and \-v are used in any case. Not that options must be specified without dash (\-), for example:
|
Options \-r, \-v, \-\-ignore\-missing\-args and \-\-mkpath are used in any case. Note that options must be specified without dash (\-), for example:
|
||||||
.PP
|
.P
|
||||||
.EX
|
.EX
|
||||||
simple_backup \-\-rsync\-options a l p
|
simple_backup \-\-rsync\-options a l p
|
||||||
.EE
|
.EE
|
||||||
.TP
|
.P
|
||||||
Check
|
Check
|
||||||
.BR rsync (1)
|
.BR rsync (1)
|
||||||
for details about the options.
|
for details about the options.
|
||||||
@@ -114,8 +129,12 @@ for details about the options.
|
|||||||
.B \-\-remote\-sudo
|
.B \-\-remote\-sudo
|
||||||
Run rsync on the remote server with sudo. This is needed if you want to preserve the owner of the files/folders to be copied (rsync \-\-owner option). For this to work the user used to login to the server obviously need to be allowed to use sudo. In addition, the user need to be able to run rsync with sudo without a password. To do this, /etc/sudoers on the server need to be edited adding a line like this one:
|
Run rsync on the remote server with sudo. This is needed if you want to preserve the owner of the files/folders to be copied (rsync \-\-owner option). For this to work the user used to login to the server obviously need to be allowed to use sudo. In addition, the user need to be able to run rsync with sudo without a password. To do this, /etc/sudoers on the server need to be edited adding a line like this one:
|
||||||
.RS
|
.RS
|
||||||
.PP
|
.P
|
||||||
<username> ALL=NOPASSWD:<path/to/rsync>
|
<username> ALL=NOPASSWD:<path/to/rsync>
|
||||||
|
.P
|
||||||
|
To be able to remove old backups generated with \-\-remote\-sudo (see \-\-keep option), also
|
||||||
|
.BR rm (1)
|
||||||
|
needs to be allowed to run without password in the same way.
|
||||||
.RE
|
.RE
|
||||||
.TP
|
.TP
|
||||||
.B \-\-numeric\-ids
|
.B \-\-numeric\-ids
|
||||||
@@ -127,6 +146,14 @@ Copy it to the default location ($HOME/.config/simple_backup) and edit it as nee
|
|||||||
It is possible to choose a directory on a remote server as destination for the backup. The files
|
It is possible to choose a directory on a remote server as destination for the backup. The files
|
||||||
are copied by rsync through SSH. Server hostname and username must be specified, either in the
|
are copied by rsync through SSH. Server hostname and username must be specified, either in the
|
||||||
configuration file, or on the command line (\(aq\-\-ssh\-host\(aq and \(aq\-\-ssh\-user\(aq options).
|
configuration file, or on the command line (\(aq\-\-ssh\-host\(aq and \(aq\-\-ssh\-user\(aq options).
|
||||||
|
.P
|
||||||
|
The output directory is a path on the server. A leading \(aq~\(aq and relative paths refer to the
|
||||||
|
home directory of the user on the server. On the command line, quote \(aq~\(aq so that the local
|
||||||
|
shell doesn\(aqt expand it, for example:
|
||||||
|
.P
|
||||||
|
.EX
|
||||||
|
simple_backup \-\-ssh\-host server \-\-ssh\-user user \-o \(aq~/backups\(aq
|
||||||
|
.EE
|
||||||
.SS AUTHENTICATION
|
.SS AUTHENTICATION
|
||||||
For authentication, it is possible to use SSH key or password.
|
For authentication, it is possible to use SSH key or password.
|
||||||
.P
|
.P
|
||||||
@@ -148,8 +175,7 @@ in order to connect to the user\(aq s SSH agent it is necessary to preserve the
|
|||||||
It is also possible to make this permanent by editing the
|
It is also possible to make this permanent by editing the
|
||||||
.B sudoers
|
.B sudoers
|
||||||
file (see
|
file (see
|
||||||
.BR sudoers (5)
|
.BR sudoers (5))
|
||||||
)
|
|
||||||
.P
|
.P
|
||||||
If SSH key authentication is not available, password authentication will be used instead.
|
If SSH key authentication is not available, password authentication will be used instead.
|
||||||
Note that in this case
|
Note that in this case
|
||||||
@@ -162,7 +188,8 @@ for details. For this reason, use SSH key authentication if possible.
|
|||||||
.SH EXIT STATUS
|
.SH EXIT STATUS
|
||||||
.TP
|
.TP
|
||||||
.B 0
|
.B 0
|
||||||
The backup was completed without errors.
|
The backup was completed without errors. This includes rsync return code 24 (some source files
|
||||||
|
vanished during the transfer), which only logs a warning.
|
||||||
.TP
|
.TP
|
||||||
.B 1
|
.B 1
|
||||||
No valid inputs selected for backup.
|
No valid inputs selected for backup.
|
||||||
@@ -174,16 +201,16 @@ Backup failed because output directory for storing the backup does not exist.
|
|||||||
Permission denied to access the output directory.
|
Permission denied to access the output directory.
|
||||||
.TP
|
.TP
|
||||||
.B 4
|
.B 4
|
||||||
rsync error (rsync returned a non-zero value).
|
rsync error (rsync returned a value other than 0 or 24).
|
||||||
.TP
|
.TP
|
||||||
.B 5
|
.B 5
|
||||||
SSH connection failed.
|
SSH connection failed.
|
||||||
.TP
|
.TP
|
||||||
.B 6
|
.B 6
|
||||||
Bad configuration file.
|
Bad configuration file or options (for example, only one of SSH host and SSH user specified).
|
||||||
.SH SEE ALSO
|
.SH SEE ALSO
|
||||||
.BR rsync (1)
|
.BR rsync (1)
|
||||||
.SH AUTHORS
|
.SH AUTHORS
|
||||||
.MT https://github.com/Fuxino
|
.MT https://git.shouldnt.work/fuxino
|
||||||
Daniele Fucini
|
Daniele Fucini
|
||||||
.ME
|
.ME
|
||||||
|
|||||||
+46
-1
@@ -1,3 +1,48 @@
|
|||||||
[build-system]
|
[build-system]
|
||||||
requires = ['setuptools']
|
requires = ['setuptools>=77']
|
||||||
build-backend = 'setuptools.build_meta'
|
build-backend = 'setuptools.build_meta'
|
||||||
|
|
||||||
|
[project]
|
||||||
|
name = "simple_backup"
|
||||||
|
dynamic = ["version"]
|
||||||
|
description = "Simple backup script that uses rsync to copy files"
|
||||||
|
readme = "README.md"
|
||||||
|
requires-python = ">=3.10"
|
||||||
|
license = "GPL-3.0-or-later"
|
||||||
|
license-files = ["LICENSE"]
|
||||||
|
authors = [
|
||||||
|
{ name = "Daniele Fucini", email = "dfucini@gmail.com" }
|
||||||
|
]
|
||||||
|
maintainers = [
|
||||||
|
{ name = "Daniele Fucini", email = "dfucini@gmail.com" }
|
||||||
|
]
|
||||||
|
classifiers = [
|
||||||
|
"Development Status :: 4 - Beta",
|
||||||
|
"Environment :: Console",
|
||||||
|
"Natural Language :: English",
|
||||||
|
"Operating System :: POSIX :: Linux",
|
||||||
|
"Programming Language :: Python :: 3",
|
||||||
|
"Programming Language :: Python :: 3.10",
|
||||||
|
"Programming Language :: Python :: 3.11",
|
||||||
|
"Programming Language :: Python :: 3.12",
|
||||||
|
"Programming Language :: Python :: 3.13",
|
||||||
|
"Programming Language :: Python :: 3.14",
|
||||||
|
"Topic :: System :: Archiving :: Backup",
|
||||||
|
]
|
||||||
|
|
||||||
|
[project.optional-dependencies]
|
||||||
|
JOURNAL = ["systemd-python"]
|
||||||
|
NOTIFICATIONS = ["dbus-python"]
|
||||||
|
REMOTE = ["paramiko>=3.2"]
|
||||||
|
|
||||||
|
[project.urls]
|
||||||
|
Homepage = "https://git.shouldnt.work/fuxino/simple_backup"
|
||||||
|
|
||||||
|
[project.scripts]
|
||||||
|
simple_backup = "simple_backup.simple_backup:simple_backup"
|
||||||
|
|
||||||
|
[tool.setuptools]
|
||||||
|
packages = ["simple_backup"]
|
||||||
|
|
||||||
|
[tool.setuptools.dynamic]
|
||||||
|
version = { attr = "simple_backup.__version__" }
|
||||||
|
|||||||
@@ -1,40 +0,0 @@
|
|||||||
[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 :: 4 - Beta
|
|
||||||
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
|
|
||||||
|
|
||||||
[options.extras_require]
|
|
||||||
JOURNAL =
|
|
||||||
systemd-python
|
|
||||||
NOTIFICATIONS =
|
|
||||||
dbus-python
|
|
||||||
REMOTE =
|
|
||||||
paramiko
|
|
||||||
|
|
||||||
[options.entry_points]
|
|
||||||
console_scripts =
|
|
||||||
simple_backup = simple_backup.simple_backup:simple_backup
|
|
||||||
|
|
||||||
@@ -1,3 +1,3 @@
|
|||||||
"""Init."""
|
"""Init."""
|
||||||
|
|
||||||
__version__ = '4.1.1'
|
__version__ = '4.3.0'
|
||||||
|
|||||||
@@ -2,9 +2,9 @@
|
|||||||
|
|
||||||
[backup]
|
[backup]
|
||||||
# Files and directories to backup. Multiple items can be separated using a comma (','). It is possible to use wildcards (i.e. '*' to match multiple characters and '~' for the user's home directory).
|
# Files and directories to backup. Multiple items can be separated using a comma (','). It is possible to use wildcards (i.e. '*' to match multiple characters and '~' for the user's home directory).
|
||||||
inputs=/home/my_home,/etc
|
inputs=/home/user
|
||||||
|
|
||||||
# Output directory.
|
# Output directory. For remote backups, this is a path on the server ('~' and relative paths refer to the home directory on the server).
|
||||||
backup_dir=/media/Backup
|
backup_dir=/media/Backup
|
||||||
|
|
||||||
# Files, directories and patterns to exclude from the backup. Multiple items can be separated using a comma.
|
# Files, directories and patterns to exclude from the backup. Multiple items can be separated using a comma.
|
||||||
@@ -18,5 +18,5 @@ keep=-1
|
|||||||
# ssh_host=
|
# ssh_host=
|
||||||
# ssh_user=
|
# ssh_user=
|
||||||
# ssh_keyfile=
|
# ssh_keyfile=
|
||||||
# remote_sudo=
|
# remote_sudo=false
|
||||||
# numeric_ids=
|
# numeric_ids=false
|
||||||
|
|||||||
+478
-249
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user