Skip to content

Commit

Permalink
Fixes:
Browse files Browse the repository at this point in the history
- Bumped PAF to Fix Logging Function
- Fixed Config File Detection
- New Session Locking System Using fcntl

Other:
- New Users Docs
- General Doc Patches
  • Loading branch information
JustinTimperio committed Sep 12, 2020
1 parent f57f610 commit d864de7
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 15 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ Pacback offers several core commands that streamline the process of creating and
*Example: `pacback -v`*

### Utilities
* - -cache, --cache_size | Calculate reported and actual cache sizes.\
*Example: `pacback -cl`*
* -cl, --clean | Clean old and orphaned pacakages along with old restore points.\
*Example: `pacback -cl`*
* -rm, --remove | Removes the selected restore point.\
Expand Down
12 changes: 12 additions & 0 deletions USER_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
**Table of Contents:**
- [Get Snapshot and Restore Point Info](https://github.com/JustinTimperio/pacback/blob/master/USER_GUIDE.md#getting-snapshot-and-restore-point-info)
- [Using Rolling System Snapshots](https://github.com/JustinTimperio/pacback/blob/master/USER_GUIDE.md#rolling-system-snapshots)
- [Creating Permanent Restore Points](https://github.com/JustinTimperio/pacback/blob/master/USER_GUIDE.md#creating-permanent-restore-points)
- [Rollback a List of Packages](https://github.com/JustinTimperio/pacback/blob/master/USER_GUIDE.md#rollback-a-list-of-packages)
- [Rolling Back to an Archive Date](https://github.com/JustinTimperio/pacback/blob/master/USER_GUIDE.md#rolling-back-to-an-archive-date)
- [Backup Version Sensitive Application Data](https://github.com/JustinTimperio/pacback/blob/master/USER_GUIDE.md#backup-version-sensitive-application-data)
Expand Down Expand Up @@ -31,6 +32,17 @@ One of the problems with rolling releases is you never know when a problem might

![Pacback Snapshot](https://i.imgur.com/GE61yqe.gif)

## Creating Permanent Restore Points

Remember that one time all your packages were working perfectly? (God that was great.) Have a production system running perfectly that needs to be updated but you don't want to backup the whole disk? With pacback restore points, you don't have to lose that version state. Restore points are user-defined version states that describe a set of packages and even configuration files on your system that you don't want to lose track of. Unlike many backup utilities pacback doesn't need backup the whole disk. Instead, it hardlinks packages with inodes without duplicating the files so that pacback can maintain the smallest possible profile on your system.

To create a restore point, then get information about it:

1. `pacback -nc -f -c 1 -l 'Production'`
2. `pacback -i rp1`

![Restore Points](https://i.imgur.com/5f5d5HI.gif)


## Rollback a List of Packages
Most issues introduced by an upgrade stem from a single package or a set of related packages. Pacback allows you to selectively rollback a list of packages using `pacback -pkg`. Packback searches your file system looking for all versions associated with each package name. When searching, Pacback attempts to avoid matching generic names used by multiple packages (I.E. *xorg* in *xorg*-server, *xorg*-docs, *xorg*-xauth). If no packages are found, the search parameters can be widened but it will likely show inaccurate results.
Expand Down
2 changes: 1 addition & 1 deletion core/pacback.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
parser.add_argument("-ls", "--list", action='store_true',
help="List information about all existing restore points and snapshots.")
parser.add_argument("-cache", "--cache_size", action='store_true',
help="Calculate a timeline of changes between snapshots.")
help="Calculate reported and actual cache sizes.")

args = parser.parse_args()
config = session.load_config()
Expand Down
2 changes: 1 addition & 1 deletion core/paf
Submodule paf updated 1 files
+3 −3 logging.py
28 changes: 15 additions & 13 deletions core/session.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#! /usr/bin/env python3
import os
import sys
import fcntl
import datetime as dt

# Local Modules
Expand All @@ -20,13 +21,15 @@ def lock(config):
if paf.am_i_root() is False:
sys.exit('Critical Error: This Command Must Be Run As Root!')

if os.path.exists(config['slock']):
sys.exit('Critical Error! Pacback Already Has An Active Session Running.')
try:
lock = os.open(config['slock'], os.O_CREAT)
fcntl.flock(lock, fcntl.LOCK_EX | fcntl.LOCK_NB)
paf.start_log(fname, config['log'])
paf.write_to_log(fname, 'Passed Root Check', config['log'])
paf.write_to_log(fname, 'Started Active Session', config['log'])

paf.start_log(fname, config['log'])
paf.write_to_log(fname, 'Passed Root Check', config['log'])
os.system('touch ' + config['slock'])
paf.write_to_log(fname, 'Started Active Session', config['log'])
except (IOError, OSError):
sys.exit('Critical Error! Pacback Already Has An Active Session Running.')


def unlock(config):
Expand All @@ -35,7 +38,6 @@ def unlock(config):
This releases the lock that was created by session.lock()
'''
fname = 'session.unlock()'
paf.rm_file(config['slock'], sudo=False)
paf.write_to_log(fname, 'Ended Active Session', config['log'])
paf.end_log(fname, config['log'], config['log_length'])

Expand Down Expand Up @@ -111,7 +113,7 @@ def hlock_check(config):
paf.write_to_log(fname, 'Passed Cooldown Check', config['log'])
else:
abort(fname, 'A Hook Lock Was Created ' + str(sec_dif) + ' Ago!',
'Aborting: The Last Snapshot Was Created Less Than ' + str(config['hook_cooldown']) + ' Seconds Ago!', config)
'Aborting: A Snapshot Was Created Less Than ' + str(config['hook_cooldown']) + ' Seconds Ago!', config)
else:
paf.write_to_log(fname, 'Passed Check, No Previous Lock Found', config['log'])

Expand All @@ -127,11 +129,11 @@ def load_config():
mandatory = ['hook_cooldown', 'max_ss', 'reboot']
optional = ['old_rp', 'keep_versions', 'reboot_offset', 'log_length', 'basepath', 'rp_paths', 'ss_paths']
default = {
'version': '2.0.1',
'paf': '4f25050',
'version': '2.0.2',
'paf': '412fd69',
'log': '/var/log/pacback.log',
'slock': '/tmp/pacback_session.lck',
'hlock': '/tmp/pacback_hook.lck',
'slock': '/var/lib/pacback/pacback_session.lck',
'hlock': '/var/lib/pacback/pacback_hook.lck',
'basepath': '/var/lib/pacback',
'rp_paths': '/var/lib/pacback/restore-points',
'ss_paths': '/var/lib/pacback/snapshots',
Expand Down Expand Up @@ -173,5 +175,5 @@ def setup(config):
paf.mk_dir(config['ss_paths'], sudo=False)
paf.write_to_log(fname, 'Created Snapshot Folder at ' + config['ss_paths'], config['log'])

if os.path.exists('/etc/pacback/config') is False:
if os.path.exists('/etc/pacback.conf') is False:
paf.write_to_log(fname, 'User Config File Is Missing!', config['log'])

0 comments on commit d864de7

Please sign in to comment.