backup_paradise 1.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of backup_paradise might be problematic. Click here for more details.
- checksums.yaml +7 -0
- data/README.md +408 -0
- data/backup_paradise.gemspec +50 -0
- data/bin/backup_for_ingrid +10 -0
- data/bin/backup_paradise +7 -0
- data/bin/windows_backup_paradise +9 -0
- data/doc/README.gen +368 -0
- data/doc/TODO.md +130 -0
- data/lib/backup_paradise/actions/README.md +2 -0
- data/lib/backup_paradise/actions/backup.rb +62 -0
- data/lib/backup_paradise/base/base.rb +502 -0
- data/lib/backup_paradise/base/colours.rb +137 -0
- data/lib/backup_paradise/base/namespace.rb +16 -0
- data/lib/backup_paradise/base/tab.rb +47 -0
- data/lib/backup_paradise/colours/colours.rb +88 -0
- data/lib/backup_paradise/constants/constants.rb +162 -0
- data/lib/backup_paradise/gui/glimmer/libui/backup_for_ingrid/backup_for_ingrid.rb +87 -0
- data/lib/backup_paradise/gui/gtk2/OLD_backup.rb +220 -0
- data/lib/backup_paradise/gui/gtk3/simple_backup_widget/create.rb +70 -0
- data/lib/backup_paradise/gui/gtk3/simple_backup_widget/misc.rb +33 -0
- data/lib/backup_paradise/gui/gtk3/simple_backup_widget/simple_backup_widget.rb +160 -0
- data/lib/backup_paradise/gui/libui/backup_for_ingrid/backup_for_ingrid.rb +99 -0
- data/lib/backup_paradise/gui/libui/simple_backup_widget/simple_backup_widget.rb +119 -0
- data/lib/backup_paradise/gui/shared_code/simple_backup_widget/simple_backup_widget_module.rb +587 -0
- data/lib/backup_paradise/gui/tk/backup.rb +108 -0
- data/lib/backup_paradise/images/BACKUP_IMAGE.png +0 -0
- data/lib/backup_paradise/images/right_arrow.png +0 -0
- data/lib/backup_paradise/project/project.rb +40 -0
- data/lib/backup_paradise/requires/require_the_backup_paradise_project.rb +18 -0
- data/lib/backup_paradise/requires/require_yaml.rb +7 -0
- data/lib/backup_paradise/tab/tab.rb +87 -0
- data/lib/backup_paradise/toplevel_methods/cliner.rb +16 -0
- data/lib/backup_paradise/toplevel_methods/config.rb +86 -0
- data/lib/backup_paradise/toplevel_methods/create_and_remove.rb +63 -0
- data/lib/backup_paradise/toplevel_methods/e.rb +16 -0
- data/lib/backup_paradise/toplevel_methods/esystem.rb +19 -0
- data/lib/backup_paradise/toplevel_methods/files_and_directories.rb +181 -0
- data/lib/backup_paradise/toplevel_methods/help.rb +93 -0
- data/lib/backup_paradise/toplevel_methods/misc.rb +153 -0
- data/lib/backup_paradise/toplevel_methods/mountpoint.rb +188 -0
- data/lib/backup_paradise/toplevel_methods/opnn.rb +27 -0
- data/lib/backup_paradise/utility_scripts/backup/backup.rb +1901 -0
- data/lib/backup_paradise/version/version.rb +19 -0
- data/lib/backup_paradise/windows/README.md +1 -0
- data/lib/backup_paradise/windows/windows.rb +101 -0
- data/lib/backup_paradise/www/backup.cgi +63 -0
- data/lib/backup_paradise/yaml/config.yml +82 -0
- data/lib/backup_paradise.rb +5 -0
- data/test/testing_toplevel_functionality.rb +11 -0
- metadata +194 -0
data/doc/README.gen
ADDED
@@ -0,0 +1,368 @@
|
|
1
|
+
DEFAULT_HEADER
|
2
|
+
|
3
|
+
# The Backup Paradise project
|
4
|
+
|
5
|
+
This project attempts to assist you - and me - in backing up data
|
6
|
+
to an **external USB** device specifically.
|
7
|
+
|
8
|
+
The project is mostly catering to my own use cases, so it may not
|
9
|
+
be very useful to other ruby users. I will try to make adjustments
|
10
|
+
so that other ruby users can use it (see the file called
|
11
|
+
**config.yml**), but this is an ongoing effort that may take
|
12
|
+
some time.
|
13
|
+
|
14
|
+
The project is primarily just a fancy **recursive copy** operation,
|
15
|
+
but it will do some minor additional notifications on the commandline,
|
16
|
+
make use of colours (if the colours gem has been installed),
|
17
|
+
automatically create some log files and even provide ruby-gtk3
|
18
|
+
bindings, as well as tk-bindings (although the latter ones are
|
19
|
+
currently incomplete).
|
20
|
+
|
21
|
+
So it is a **recursive copy** script with some add-ons really,
|
22
|
+
nothing really sophisticated aside from this on top.
|
23
|
+
|
24
|
+
The project has **one major goal** and a **few minor goals**.
|
25
|
+
|
26
|
+
The **major goal** is **to be usable as a backup-assistant**,
|
27
|
+
on both linux, but also on windows systems.
|
28
|
+
|
29
|
+
The **minor goals** include:
|
30
|
+
|
31
|
+
- **Flexibility**, to also allow us to back up only
|
32
|
+
individual files or individual directories. The user should
|
33
|
+
be able to specify **what** has to be backed up.
|
34
|
+
|
35
|
+
- Notify the user about the status of the backup-operation
|
36
|
+
and prior backup-operations.
|
37
|
+
|
38
|
+
- Provide some **simple GUI bindings** to use this project,
|
39
|
+
in particular for both ruby-gtk and ruby-tk. The latter
|
40
|
+
so that we can use this on windows.
|
41
|
+
|
42
|
+
## General usage of the BackupParadise project - backing up data via ruby
|
43
|
+
|
44
|
+
For the time being, I have aliased the main executable at
|
45
|
+
**bin/backup_paradise** onto:
|
46
|
+
|
47
|
+
backup_paradise
|
48
|
+
|
49
|
+
To then use this, I can issue the following commands:
|
50
|
+
|
51
|
+
backup_paradise usb1
|
52
|
+
backup_paradise usb2
|
53
|
+
backup_paradise tousb1
|
54
|
+
backup_paradise tousb2
|
55
|
+
backup_paradise tousb3
|
56
|
+
backup_paradise tousb4
|
57
|
+
|
58
|
+
Depending on where the **external USB device** is mounted.
|
59
|
+
|
60
|
+
What does an argument, such as **usb1**, imply?
|
61
|
+
|
62
|
+
This used to refer to the hardcoded path at <b>/Mount/USB1/</b>
|
63
|
+
on my home system. **usb2** would then point at
|
64
|
+
<b>/Mount/USB2/</b> and so forth.
|
65
|
+
|
66
|
+
These 'main aliases' can also be accessed via some shortcuts,
|
67
|
+
such as "tousb1", without the quotes. See the examples listed
|
68
|
+
above.
|
69
|
+
|
70
|
+
I adopted this scheme after having used **GoboLinux**. Note that
|
71
|
+
this used to be valid from **December 2018** up to **May 2021**.
|
72
|
+
|
73
|
+
In **May 2021** this approach was changed. While I still use
|
74
|
+
the above instructions, such as via **backup_paradise usb1**,
|
75
|
+
a .yml file now decides the target directory. So, usb1,
|
76
|
+
usb2 and so forth, are now simply aliases to whatever the
|
77
|
+
.yml file specifies. The advantage of this approach is that
|
78
|
+
other users can re-define the targets there - simply have
|
79
|
+
a look at the **config.yml** file and change it if you
|
80
|
+
would like to. (Of course overruling this via the commandline
|
81
|
+
still works, so you don't really need to have to modify the
|
82
|
+
config.yml file.)
|
83
|
+
|
84
|
+
Other mount points can also be used, although not with a
|
85
|
+
convenience shortcut. Have a look at the option
|
86
|
+
**--backup-to=/opt/** documented elsewhere in this
|
87
|
+
file, to specify another base-directory to use.
|
88
|
+
|
89
|
+
## The configuration file called config.yml
|
90
|
+
|
91
|
+
The **BackupParadise project** comes with a small configuration file,
|
92
|
+
called **config.yml**, in the **yaml/** subdirectory.
|
93
|
+
|
94
|
+
This is an optional file, though - if it does not exist then the
|
95
|
+
project will ignore this file completely and use internal
|
96
|
+
defaults as-is. But if it is available, and it can be found by
|
97
|
+
ruby, then it will be used as **the default configuration**.
|
98
|
+
|
99
|
+
Since as of **September 2021* the **config.yml** file
|
100
|
+
has the following **five main configuration settings**:
|
101
|
+
|
102
|
+
use_this_program_to_rename_tabs: String
|
103
|
+
show_popup_notification: Boolean
|
104
|
+
use_system_cp: Boolean
|
105
|
+
backup_these_directories: Array
|
106
|
+
local_audio_directory: String
|
107
|
+
|
108
|
+
The first three entries are not so important, but the fourth
|
109
|
+
entry is quite important, because this Array specifies which
|
110
|
+
directories we want to back up and thus copy. The fifth entry
|
111
|
+
can be used to denote your local collection of audio files,
|
112
|
+
if these are kept in a directory. I use **/home/x/songs/** for
|
113
|
+
this.
|
114
|
+
|
115
|
+
More options may be added in the future, but I will try to only
|
116
|
+
add options that make sense, rather than overwhelm users with
|
117
|
+
lots of configuration options.
|
118
|
+
|
119
|
+
The individual aliases, such as usb1, usb2, and so forth, are
|
120
|
+
also specified now:
|
121
|
+
|
122
|
+
usb1: /Mount/USB1/
|
123
|
+
usb2: /Mount/USB2/
|
124
|
+
usb3: /Mount/USB3/
|
125
|
+
usb4: /Mount/USB4/
|
126
|
+
usb5: /Mount/USB5/
|
127
|
+
|
128
|
+
The rationale for these default to my home setup, where I
|
129
|
+
mount devices to these directories (on Linux).
|
130
|
+
|
131
|
+
## Log files
|
132
|
+
|
133
|
+
The BackupParadise project will try to log as to what has happened,
|
134
|
+
since as of **May 2018**. Several different log files may be created.
|
135
|
+
|
136
|
+
If there is more than one log file stored at the target device
|
137
|
+
then the current behaviour is to delete all but one log file.
|
138
|
+
|
139
|
+
Another log file that may commonly be used is the one
|
140
|
+
that targets the file <b>/Depot/Temp/backup.log</b>. This
|
141
|
+
will, however had, only work if the directory **/Depot/Temp/**
|
142
|
+
exists, which is the case on my home system. The whole gem here
|
143
|
+
is heavily tailored to my own needs - I can adapt it to meet
|
144
|
+
other people's wishes if necessary, of course.
|
145
|
+
|
146
|
+
The **format** of the log file going into **backup.log** is
|
147
|
+
simply how long it took to make the backup, in seconds, and
|
148
|
+
the exact date when that particular log file was created. This
|
149
|
+
is equal to when the backup-operation happened, too.
|
150
|
+
|
151
|
+
## Backing up individual directories
|
152
|
+
|
153
|
+
If you have a directory called **FOOBAR/**, then you can back
|
154
|
+
it up simply by issuing:
|
155
|
+
|
156
|
+
backup_paradise --FOOBAR
|
157
|
+
backup_paradise FOOBAR
|
158
|
+
|
159
|
+
Whichever variant you prefer. Note that this requires that the
|
160
|
+
external device has been mounted already. You can set where
|
161
|
+
the device should reside via:
|
162
|
+
|
163
|
+
BackupParadise.set_mounted_path()
|
164
|
+
|
165
|
+
Simply pass the directory that you may wish to use for backup
|
166
|
+
purpose there.
|
167
|
+
|
168
|
+
Note that **class AdvancedBackup** will assume a certain target
|
169
|
+
device automatically, tailored to my own system. This is usually
|
170
|
+
at **/Mount/USB1** for the first mounted USB device on my
|
171
|
+
system.
|
172
|
+
|
173
|
+
If you wish to overrule that and use another target, which you
|
174
|
+
may most likely want to do, then you can use any of the
|
175
|
+
following commandline flags for this:
|
176
|
+
|
177
|
+
backup_paradise --use-this-as-target-for-backup=/opt/
|
178
|
+
backup_paradise --use-this-as-target=/opt/
|
179
|
+
backup_paradise --backup-to=/opt/
|
180
|
+
|
181
|
+
In this case **/opt/** would be the target that you use as **source
|
182
|
+
directory** for the backup-operation.
|
183
|
+
|
184
|
+
If you wish to backup the **/Programs/** hierarchy, should you
|
185
|
+
keep an **AppDir layout** on your system, then this commandline
|
186
|
+
invocation may be of help:
|
187
|
+
|
188
|
+
backup_paradise --programs-dir
|
189
|
+
|
190
|
+
To backup the **/home/x/studium/** directory, the following
|
191
|
+
commands are possible:
|
192
|
+
|
193
|
+
backup_paradise --studium-dir
|
194
|
+
backup_paradise --studium-directory
|
195
|
+
backup_paradise --studium
|
196
|
+
|
197
|
+
To backup, on my home system, the **/AUTOGENERATED/**
|
198
|
+
directory, I do:
|
199
|
+
|
200
|
+
backup_paradise --autogenerated
|
201
|
+
|
202
|
+
## Miscellaneous comments
|
203
|
+
|
204
|
+
The **BackupParadise** project has been rewritten a few times already
|
205
|
+
over the years.
|
206
|
+
|
207
|
+
In the past there was an instance variable in class AdvancedBackup
|
208
|
+
called **@last_backup_directory**, which was pointing to an absolute
|
209
|
+
path such as **/Mount/USB1/last_backup-13.08.2018-21:11:15/**.
|
210
|
+
|
211
|
+
It is no longer in use, but I keep it as a reference hint to
|
212
|
+
myself - who knows what may be changed in the future.
|
213
|
+
|
214
|
+
## Specific examples
|
215
|
+
|
216
|
+
This subsection details some invocation examples in a short way.
|
217
|
+
|
218
|
+
Some of these will only work on my home system for the time being,
|
219
|
+
until I have sufficiently changed the project to allow more
|
220
|
+
flexibility in this regard.
|
221
|
+
|
222
|
+
Backup all audio-files to **/opt/**:
|
223
|
+
|
224
|
+
backup_paradise --backup-to=/opt/ --audio-dir
|
225
|
+
|
226
|
+
Backup all relevant entries into the default chroot target (on
|
227
|
+
my home system):
|
228
|
+
|
229
|
+
backup_paradise --chroot
|
230
|
+
|
231
|
+
## How do I make use of this project
|
232
|
+
|
233
|
+
I make use of the **backup_paradise** project to back up relevant
|
234
|
+
data on my home system. For example, all source-archives that
|
235
|
+
are registered within the **RBT project** I also keep available
|
236
|
+
locally. Then there is my ruby code, other files, and possibly
|
237
|
+
books, papers and tutorials stored in .pdf format.
|
238
|
+
|
239
|
+
In **September 2020**, the regular backup size was **54G** per
|
240
|
+
backup-action, mostly owing to the source archives (krita
|
241
|
+
alone occupies more than 167 MB, for example). This is way too
|
242
|
+
much, in my opinion, because it takes about **half an hour**
|
243
|
+
or so to back up on USB 2.0 already.
|
244
|
+
|
245
|
+
I will have to keep reducing file size and removing stuff that
|
246
|
+
I no longer need; aka do some clean-up. Or perhaps hope that
|
247
|
+
future USB variants will improve things here.
|
248
|
+
|
249
|
+
At any rate, this subsection shows just a bit how I may use
|
250
|
+
the project.
|
251
|
+
|
252
|
+
My usual go-to alias is:
|
253
|
+
|
254
|
+
rbackup usb1
|
255
|
+
|
256
|
+
to backup to the mount point /Mount/USB1.
|
257
|
+
|
258
|
+
This is the command invocation I tend to use most frequently
|
259
|
+
so.
|
260
|
+
|
261
|
+
## class BackupParadise::Backup
|
262
|
+
|
263
|
+
This class is the main interface for the BackupParadise project.
|
264
|
+
|
265
|
+
For a list of documented options, pass in **--help**.
|
266
|
+
|
267
|
+
A few examples will be mentioned here as well, in a succinct
|
268
|
+
manner:
|
269
|
+
|
270
|
+
rbackup --pwd # backup into the current working directory
|
271
|
+
|
272
|
+
## BackupParadise.simple_backup
|
273
|
+
|
274
|
+
**BackupParadise.simple_backup** can be used as a simpler alternative
|
275
|
+
to class BackupParadise::Backup. While the latter class is very
|
276
|
+
feature-rich, sometimes you may want to use
|
277
|
+
**BackupParadise.simple_backup()** instead.
|
278
|
+
|
279
|
+
Usage examples:
|
280
|
+
|
281
|
+
BackupParadise.simple_backup(:audio, '/Mount/HDD1/')
|
282
|
+
BackupParadise.simple_backup(:audio, :usb1)
|
283
|
+
|
284
|
+
## Backup time (statistics)
|
285
|
+
|
286
|
+
This subsection is just a remainder for me how long backing up all
|
287
|
+
my dataset (which is a LOT) takes. These times are gathered on
|
288
|
+
Linux.
|
289
|
+
|
290
|
+
Ideally this time should be as small as possible, but evidently,
|
291
|
+
the more time that has to be transferred, the longer it will
|
292
|
+
take. This refers to about 100 GB or more right now. I am open
|
293
|
+
for any suggestions to cut the time down.
|
294
|
+
|
295
|
+
The measurements happen when there is a low CPU load.
|
296
|
+
|
297
|
+
04.06.2021: 39.17 minutes
|
298
|
+
|
299
|
+
## GUI components
|
300
|
+
|
301
|
+
Right now the **GTK3 version** (ruby-gtk3) is the most advanced GUI
|
302
|
+
component of this project - but it is still rather limited. The
|
303
|
+
primary point of the gtk-widgets for the project is to demonstrate
|
304
|
+
what **could** be done: we want to show what is possible, in
|
305
|
+
the event that others may want to build upon these ideas.
|
306
|
+
|
307
|
+
Additionally I am working on **ruby-tk** code as well, just so
|
308
|
+
that this project can be used on windows (addendum in August
|
309
|
+
2021: this has been superceded by ruby-libui, which is a LOT
|
310
|
+
simpler to use on windows). The priority for ruby-tk is lower
|
311
|
+
than that of the ruby-gtk3 code. (In the future, one
|
312
|
+
day, we may try to use the same, unified code base for
|
313
|
+
GUIs, but this is a minor, additional goal.)
|
314
|
+
|
315
|
+
Yet another use case is ruby-libui, so in the long run it is
|
316
|
+
planned to add at the least three different widget sets,
|
317
|
+
as well as "GUIs" for the world wide web, such as via
|
318
|
+
<b>sinatra</b>.
|
319
|
+
|
320
|
+
You can try to invoke the **GUI components** from the commandline,
|
321
|
+
possibly via any of the following flags:
|
322
|
+
|
323
|
+
backup_paradise --gui
|
324
|
+
backup_paradise --gtk # This variant now defaults to ruby-gtk3.
|
325
|
+
|
326
|
+
Or more specifically:
|
327
|
+
|
328
|
+
backup_paradise --gtk3
|
329
|
+
|
330
|
+
There used to be gtk2-bindings, but they currently (**May 2021**)
|
331
|
+
do not work very well. In **August 2021** I abandoned the ruby-gtk2
|
332
|
+
code completely - new GUI code will be written either in ruby-gtk3
|
333
|
+
and/or in ruby-libui. ruby-gtk2 is still nice, but ruby-gtk3 allows
|
334
|
+
for more flexibility, in particular in regards to **CSS**.
|
335
|
+
|
336
|
+
In **September 2021** I rewrote the old ruby-gtk3 code. The current
|
337
|
+
iteration now looks like this:
|
338
|
+
|
339
|
+
<img src="https://i.imgur.com/g1dxzAb.png" style="margin-left: 2em">
|
340
|
+
|
341
|
+
The code base for that class is now largely a module, which I use
|
342
|
+
for libui-bindings too. In the long run I would like to have
|
343
|
+
ruby-tk and fxruby support as well as for the www (via sinatra
|
344
|
+
and .cgi files). Stay tuned in this regard, but don't expect this
|
345
|
+
to come too soon.
|
346
|
+
|
347
|
+
## Automounting
|
348
|
+
|
349
|
+
Since as of <b>March 2023</b> it is possible to automount a
|
350
|
+
second harddisc (should it exist). This is currently only
|
351
|
+
the case when the underlying system is a roebe-system,
|
352
|
+
and when the default mount target /Mount/HDD, is NOT
|
353
|
+
mounted yet. If this is the case then automounting will
|
354
|
+
occur, using a hardcoded command.
|
355
|
+
|
356
|
+
In the future this may be improved, including automounting
|
357
|
+
of USB-devices. This has to be revisited eventually; for
|
358
|
+
now the code that was added has to suffice.
|
359
|
+
|
360
|
+
## Licence
|
361
|
+
|
362
|
+
Since as of **August 2021** the MIT licence is used for new releases of
|
363
|
+
this gem. While the GPL is a fine licence in and by itself, I simply do
|
364
|
+
not have the time or willingness to want to enforce it for such a simple
|
365
|
+
project like **backup_paradise**. MIT is much simpler to adhere to as
|
366
|
+
well, so there we go.
|
367
|
+
|
368
|
+
ADD_CONTACT_INFORMATION
|
data/doc/TODO.md
ADDED
@@ -0,0 +1,130 @@
|
|
1
|
+
...........................................................................
|
2
|
+
(1) → Continue with the ruby-tk bindings on windows. Make this useable
|
3
|
+
one day. Improve the ruby-tk bindings. And the fxruby bindings
|
4
|
+
too.
|
5
|
+
...........................................................................
|
6
|
+
(2) → (Of course overruling this via the commandline
|
7
|
+
still works, so you don't really need to have to modify the
|
8
|
+
config.yml file.)
|
9
|
+
^^^ enable this
|
10
|
+
^^^ we need a way to overrule these dirs such as:
|
11
|
+
--use-these-directories=/home/x,/home/z
|
12
|
+
^^^ and test it. AND document it too.
|
13
|
+
...........................................................................
|
14
|
+
(3) → target_hdd_does_not_have_enough_space_left?
|
15
|
+
^^^ fix this. hmmm
|
16
|
+
...........................................................................
|
17
|
+
(4) → add some functionality to mount USB devices and umount them again
|
18
|
+
# ========================================================================= #
|
19
|
+
# === mount_device
|
20
|
+
#
|
21
|
+
# Normal usage is to call this from:
|
22
|
+
#
|
23
|
+
# scan_for_usb_entries
|
24
|
+
#
|
25
|
+
# ========================================================================= #
|
26
|
+
def mount_device(which_one = ENV['USB1'])
|
27
|
+
@target_device = which_one
|
28
|
+
e "Now mounting device #{@which_device_entry} "+
|
29
|
+
"to #{@target_device}", CII
|
30
|
+
tmp = "mount #{@which_device_entry} #{@target_device}"
|
31
|
+
system(tmp)
|
32
|
+
@date # zeigt einfach nur das aktuelle datum an
|
33
|
+
end
|
34
|
+
|
35
|
+
# ========================================================================= #
|
36
|
+
# === pre_backup_process
|
37
|
+
#
|
38
|
+
#
|
39
|
+
# What is this method doing?
|
40
|
+
#
|
41
|
+
# It does these things in the following order:
|
42
|
+
##
|
43
|
+
# (a) renames last_backup dir to backup_DAY.MONTH.YEAR
|
44
|
+
# (b) Deletes log_last_backup file (which contains time of last update)
|
45
|
+
# (c) Deletes already existing backup dirs before it continues.
|
46
|
+
# (d) Creates directories.
|
47
|
+
#
|
48
|
+
# base_dir signifies the absolute target.
|
49
|
+
# You are in /Mount/USB1 when this method is started.
|
50
|
+
# ========================================================================= #
|
51
|
+
|
52
|
+
# ========================================================================= #
|
53
|
+
# === backup_system
|
54
|
+
#
|
55
|
+
# backup_system() to backup your system. This method is the actual working
|
56
|
+
# dog of this script. It accepts one main argument, a symbol, which
|
57
|
+
# defaults to nogtk to avoid using gtk, and which also can use tohdd
|
58
|
+
# to only backup to my (2nd) harddrive.
|
59
|
+
#
|
60
|
+
# The mode argument should be either one of these:
|
61
|
+
# :nogtk
|
62
|
+
# :tohdd
|
63
|
+
# :tousb
|
64
|
+
# :data_only # this also assumes :tousb
|
65
|
+
# ========================================================================= #
|
66
|
+
def backup_system(mode = :nogtk, sleep_for_this_time = 0)
|
67
|
+
pre_backup_process() # all processes before starting backuping
|
68
|
+
# Now splitting towards mode content
|
69
|
+
case mode.to_sym
|
70
|
+
# dont use gtk
|
71
|
+
when :nogtk
|
72
|
+
report_backup_process_to('USB device')
|
73
|
+
my_sys_cmd = 'cp -vr /Users/x/* .'
|
74
|
+
sys(my_sys_cmd)
|
75
|
+
synchronize
|
76
|
+
# Because my hdd is so slow, we nice the process
|
77
|
+
# on -19. Not very important.
|
78
|
+
when :tohdd, :festplatte, :hdd
|
79
|
+
report_backup_process_to('second HDD')
|
80
|
+
backup :audio_dir, :pkg_dir, :system_dir
|
81
|
+
when :data_only, :dataonly, :data, :donly, :onlydata
|
82
|
+
report_backup_process_to('Data only (default into USB)')
|
83
|
+
my_sys_cmd='nice -19 cp -vr /Users/x/DATA/* .'
|
84
|
+
e(my_sys_cmd)
|
85
|
+
sleep(sleep_for_this_time) # sleeping so that user gets a chance to view the command.
|
86
|
+
sys(my_sys_cmd)
|
87
|
+
# tousb backup
|
88
|
+
when :tousb, :tousb1, :tousb2, :tousb3, :tousb4
|
89
|
+
report_backup_process_to('USB Removable media')
|
90
|
+
my_sys_cmd = 'nice -19 cp -vr /Users/x/* .'
|
91
|
+
e(my_sys_cmd)
|
92
|
+
sleep(sleep_for_this_time) # sleeping so that user gets a chance to view the command.
|
93
|
+
pp Dir['*']
|
94
|
+
sys(my_sys_cmd)
|
95
|
+
backup :audio_dir, :pkg_dir, :system_dir
|
96
|
+
synchronize # must sync
|
97
|
+
# else. Nah, there are no "unhandled cases".
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
# ========================================================================= #
|
102
|
+
# === change_to_device_and_start_backup
|
103
|
+
# ========================================================================= #
|
104
|
+
def change_to_device_and_start_backup(which_mode = @array_arg)
|
105
|
+
if Dir.pwd.include? ENV['MY_MOUNT']
|
106
|
+
# Prepend the string 'backup_'
|
107
|
+
@dir_name = 'last_backup' # name for our backup dir. Normally sets to: last_backup
|
108
|
+
# which_mode decides what to do. default is in else
|
109
|
+
# The second arg to backup_system means sleep_for_n_seconds
|
110
|
+
case which_mode.to_s
|
111
|
+
when 'no-gtk','nogtk'
|
112
|
+
backup_system()
|
113
|
+
when 'tousb3','usb3','3'
|
114
|
+
backup_system(:tousb3, 2)
|
115
|
+
when 'data_only', 'dataonly', 'data', 'donly', 'onlydata'
|
116
|
+
backup_system(:data_only, 2)
|
117
|
+
end
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
_ = RBackup.new
|
122
|
+
_.scan_for_usb_entries
|
123
|
+
_.change_to_device_and_start_backup # also invokes backup_system
|
124
|
+
^^^
|
125
|
+
...........................................................................
|
126
|
+
(5) enhance the libui interface
|
127
|
+
ideally we should use the same code base, but in September 2021
|
128
|
+
this did not work that well, so I abandoned this for now.
|
129
|
+
At a later point in time we have to re-evaluate this.
|
130
|
+
...........................................................................
|
@@ -0,0 +1,62 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
# Encoding: UTF-8
|
3
|
+
# frozen_string_literal: true
|
4
|
+
# =========================================================================== #
|
5
|
+
# === BackupParadise::Actions
|
6
|
+
# =========================================================================== #
|
7
|
+
# require 'backup_paradise/actions/backup.rb'
|
8
|
+
# =========================================================================== #
|
9
|
+
module BackupParadise
|
10
|
+
|
11
|
+
module Actions
|
12
|
+
|
13
|
+
require 'backup_paradise/project/project.rb'
|
14
|
+
require 'backup_paradise/requires/require_yaml.rb'
|
15
|
+
require 'backup_paradise/toplevel_methods/e.rb'
|
16
|
+
|
17
|
+
# ========================================================================= #
|
18
|
+
# === BackupParadise::Actions.e
|
19
|
+
# ========================================================================= #
|
20
|
+
def self.e(i = '')
|
21
|
+
::BackupParadise.e(i)
|
22
|
+
end
|
23
|
+
|
24
|
+
# ========================================================================= #
|
25
|
+
# === BackupParadise::Actions.backup
|
26
|
+
#
|
27
|
+
# This method requires a Hash as input-argument. This Hash must provide
|
28
|
+
# some basic information, such as to which target we will backup onto.
|
29
|
+
# ========================================================================= #
|
30
|
+
def self.backup(
|
31
|
+
i = ARGV,
|
32
|
+
hash = {
|
33
|
+
backup_to_this_target: :usb1
|
34
|
+
}
|
35
|
+
)
|
36
|
+
if block_given?
|
37
|
+
yielded = yield
|
38
|
+
if yielded.is_a? Hash
|
39
|
+
hash.merge!(yielded)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
# ======================================================================= #
|
43
|
+
# === :commandline_arguments
|
44
|
+
#
|
45
|
+
# The key :backup_to_this_target is mandatory.
|
46
|
+
# ======================================================================= #
|
47
|
+
if i.is_a?(Array) and !i.empty?
|
48
|
+
hash[:commandline_arguments] = i
|
49
|
+
end
|
50
|
+
# ======================================================================= #
|
51
|
+
# Delegate to a specialized class next.
|
52
|
+
# ======================================================================= #
|
53
|
+
require 'backup_paradise/utility_scripts/backup/backup.rb'
|
54
|
+
BackupParadise::Backup.new(hash)
|
55
|
+
end
|
56
|
+
|
57
|
+
end; end
|
58
|
+
|
59
|
+
if __FILE__ == $PROGRAM_NAME
|
60
|
+
BackupParadise::Actions.backup(ARGV)
|
61
|
+
end # actionbackup
|
62
|
+
# actionbackup --help
|