1. Overview
The RsyncTask module provides RSYNC transfer execution and log parsing for BastionGuard Backup. It builds snapshot or restore RSYNC commands, tracks progress and transfer statistics, parses itemized logs into FileItem objects, and finalizes task state.
The file declares multiple related types that cooperate inside the same utility layer.
The implementation is written in Vala and uses GLib/GIO together with the application utility namespaces required by the file.
2. Dependencies and Integration
The module imports:
TeeJee.LoggingTeeJee.FileSystemTeeJee.JsonHelperTeeJee.ProcessHelperTeeJee.SystemTeeJee.Misc
Key runtime integrations include:
- Gee – typed lists, maps, queues, or collection operations
- GIO/GLib streams – filesystem and process I/O
3. Declared Types
3.1 RsyncTask
public class RsyncTask : AsyncTask
This class encapsulates the state and operations described by this source file.
3.2 RegexType
private enum RegexType
This enumeration defines the finite states or modes consumed by the module.
RegexType contains:
Status
Created
LogCreated
Deleted
LogDeleted
Modified
LogModified
Unchanged
LogUnchanged
TotalSize
Count
4. State, Properties, Constants, and Signals
Public and protected state
public bool delete_extra– Boolean state controlling or reporting delete extra.public bool delete_after– Boolean state controlling or reporting delete after.public bool delete_excluded– Boolean state controlling or reporting delete excluded.public bool relative– Boolean state controlling or reporting relative.public string rsync_log_file– Filesystem-related value used for rsync log file.public string exclude_from_file– Filesystem-related value used for exclude from file.public string link_from_path– Filesystem-related value used for link from path.public string source_path– Filesystem-related value used for source path.public string dest_path– Filesystem-related value used for dest path.public bool verbose– Boolean state controlling or reporting verbose.public bool io_nice– Boolean state controlling or reporting io nice.public bool dry_run– Boolean state controlling or reporting dry run.public GLib.Queue<string> status_lines– Status value used to track status lines.public int64 status_line_count– Counter associated with status line count.public int64 total_size– Size or capacity value associated with total size.public int64 count_created– Counter associated with count created.public int64 count_deleted– Counter associated with count deleted.public int64 count_modified– Counter associated with count modified.public int64 count_checksum– Counter associated with count checksum.public int64 count_size– Counter associated with count size.public int64 count_timestamp– Counter associated with count timestamp.public int64 count_permissions– Counter associated with count permissions.public int64 count_owner– Counter associated with count owner.public int64 count_group– Counter associated with count group.public int64 count_unchanged– Counter associated with count unchanged.public StringBuilder log– Runtime state used by the module.
Internal state
private Regex[] regex_list– Collection used to store regex list.
5. Public API and Operational Methods
5.1 RsyncTask()
public RsyncTask()
Initializes the object state, allocates required collections or widgets, and applies constructor parameters.
5.2 prepare()
public override void prepare()
Implements the prepare operation for this module.
5.3 build_script()
protected override string build_script()
Constructs the RSYNC command from source, destination, link-destination, exclusion, deletion, relative-path, dry-run, verbosity, and I/O-priority settings.
5.4 parse_log()
public Gee.ArrayList<FileItem> parse_log(string log_file_path)
Parses an RSYNC itemized log into FileItem records and generates a simplified changes log.
- Performs filesystem access and handles files or directories through GLib or TeeJee helpers.
- Uses regular expressions to parse or validate text output.
- Catches runtime errors locally and reports them through the logging layer or return value.
5.5 parse_stdout_line()
public override void parse_stdout_line(string out_line)
Parses stdout line and updates structured runtime data.
5.6 parse_stderr_line()
public override void parse_stderr_line(string err_line)
Parses stderr line and updates structured runtime data.
5.7 update_progress_parse_console_output()
public bool update_progress_parse_console_output (string line)
Implements the update progress parse console output operation for this module.
- Uses regular expressions to parse or validate text output.
5.8 finish_task()
protected override void finish_task()
Implements the finish task operation for this module.
- Performs filesystem access and handles files or directories through GLib or TeeJee helpers.
6. Internal Helpers
6.1 init_regular_expressions()
private void init_regular_expressions()
Initializes regular expressions and prepares it for use.
7. Filesystem Paths and Resource Locations
The source references the following absolute or template paths:
/./
Some values are templates completed at runtime with application names, process IDs, device identifiers, or file names.
8. External Commands and System Interfaces
The module constructs, checks, or parses commands containing:
ionice -c2 -n7
rsync -aii
Execution success is determined from command exit status and, where applicable, parsed standard output or standard error.
9. Operational Flow
- Initialize object state, widgets, regular expressions, paths, or generated scripts.
- Transform raw values, command output, or metadata into structured or display-ready form.
- Finalize the operation and release files, mounts, child processes, widgets, or cached state.
10. Error Handling and Diagnostics
- GLib and filesystem exceptions are caught locally in the operations that can fail.
- The TeeJee logging layer records errors, debug state, generated commands, and operational messages.
11. Runtime and Security Considerations
- Persistence: direct JSON writes may benefit from temporary-file and atomic-rename handling when configuration integrity is critical.
- Output parsing: parsers depend on stable external-command or system-file formats and should be tested across distributions.
12. Licensing
The source is distributed under the GNU General Public License version 2 or any later version.
The source header identifies:
Copyright 2012-2018 Tony George <teejeetech@gmail.com>
