|
1 | 1 |
|
2 | 2 | # Pacman Backup
|
3 | 3 |
|
4 |
| -Backup tool for off-the-grid updates via portable USB sticks or (mesh) LAN networks. |
| 4 | +Offline Pacman Cache management tool that allows off-the-grid updates via |
| 5 | +sneakernet (usb drives) or mesh Wi-Fi networks. |
5 | 6 |
|
6 | 7 |
|
7 | 8 | ## Share Updates via USB Drive
|
8 | 9 |
|
9 |
| -In the below example, make sure that `pacman-usbdrive` is writable. |
10 |
| -Replace the path with the correct one that points to your mounted USB drive. |
| 10 | +In the below example, make sure that `usb-drive` is writable. Replace the path with |
| 11 | +the correct one that points to your mounted USB drive. |
11 | 12 |
|
12 |
| -**Step 1**: |
13 |
| - |
14 |
| -On the machine with internet connection, insert and mount the USB drive. |
15 |
| - |
16 |
| -Use `pacman-backup archive` to copy the package cache to the backup folder. |
17 |
| -Use `pacman-backup cleanup` to remain only the latest version of each package. |
18 |
| - |
19 |
| -The `archive` action will also copy the necessary database files for `pacman -Sy`. |
| 13 | +**Step 1**: On the machine _with_ internet connection, insert and mount the USB drive. |
20 | 14 |
|
21 | 15 | ```bash
|
22 | 16 | # Machine with internet connection
|
23 |
| - |
24 |
| -sudo pacman -Sy; |
25 |
| -sudo pacman -Suw; |
26 |
| - |
27 |
| -pacman-backup archive /run/media/$USER/pacman-usbdrive; |
28 |
| -pacman-backup cleanup /run/media/$USER/pacman-usbdrive; |
| 17 | +pacman-backup download /run/media/$USER/usb-drive; |
| 18 | +pacman-backup cleanup /run/media/$USER/usb-drive; |
29 | 19 | sync;
|
30 | 20 |
|
31 |
| -# Unmount the USB drive and walk to other machine |
| 21 | +# Unmount the USB drive and sneak/walk to other machine |
32 | 22 | ```
|
33 | 23 |
|
34 |
| -**Step 2**: |
35 |
| - |
36 |
| -On the machine without internet connection, insert and mount the USB drive. |
37 |
| - |
38 |
| -Copy the necessary database files to pacman's `sync` folder (which is `$DBPath/sync` of `pacman.conf`). |
39 |
| - |
40 |
| -Use `pacman-backup upgrade` to update from the backupfolder. |
41 |
| -This will output the pacman command that you should verify manually before executing it. |
| 24 | +**Step 2**: On the machine _without_ internet connection, insert and mount the USB drive. |
42 | 25 |
|
43 | 26 | ```bash
|
44 | 27 | # Machine without internet connection
|
45 |
| - |
46 |
| -sudo cp /run/media/$USER/pacman-usbdrive/sync/*.db /var/lib/pacman/sync/; |
47 |
| -pacman-backup upgrade /run/media/$USER/pacman-usbdrive; |
48 |
| - |
49 |
| -# :: Use this to install upgrades from cache: |
50 |
| -# (...) pacman -U command (...) |
| 28 | +pacman-backup upgrade /run/media/$USER/usb-drive; |
51 | 29 | ```
|
52 | 30 |
|
| 31 | +## Share Updates via Wi-Fi Mesh Network |
53 | 32 |
|
54 |
| -## Share Updates via LAN Connection |
55 |
| - |
56 |
| -In the below example, the machine with internet connection has the IP `192.168.0.10`. |
| 33 | +In the below example, the machine _with_ internet connection has the IP `192.168.0.10`. |
57 | 34 | Replace the IP with the correct one that matches your setup. If in doubt, use `ip` or `ifconfig`.
|
58 | 35 |
|
59 | 36 |
|
60 |
| -**Step 1**: |
61 |
| - |
62 |
| -On the machine with internet connection, connect the LAN cable (and internet connection). |
63 |
| - |
64 |
| -Use `pacman-backup serve` to start a pacman server that can be used by other pacman clients. |
| 37 | +**Step 1**: On the machine with internet connection, download all updates and serve them as |
| 38 | +local pacman archive mirror. |
65 | 39 |
|
66 | 40 | ```bash
|
67 | 41 | # Machine with internet connection
|
68 |
| - |
69 |
| -sudo pacman -Sy; |
70 |
| -sudo pacman -Suw; |
71 |
| - |
| 42 | +sudo pacman-backup download; |
72 | 43 | pacman-backup serve;
|
73 | 44 | ```
|
74 | 45 |
|
75 |
| -**Step 2**: |
76 |
| - |
77 |
| -On the machine without internet connection, connect the LAN cable and verify that the server |
78 |
| -(the machine with internet connection) is reachable via its IP. If in doubt, use `ping`. |
79 |
| - |
80 |
| -Use `pacman-backup download 192.168.0.10` to download the packages to pacman's package cache. |
81 |
| - |
82 |
| -Use `pacman-backup upgrade` to update from the local pacman cache. |
83 |
| -This will output the pacman command that you should verify manually before executing it. |
| 46 | +**Step 2**: On the machine _without_ direct internet connection, download updates from the |
| 47 | +local pacman archive mirror. |
84 | 48 |
|
85 | 49 | ```bash
|
86 | 50 | # Machine without internet connection
|
87 |
| - |
88 |
| -sudo pacman-backup download 192.168.0.10; |
89 |
| -pacman-backup upgrade; |
| 51 | +sudo pacman-backup download http://192.168.0.10:15678/; |
| 52 | +sudo pacman-backup upgrade; |
90 | 53 | ```
|
91 | 54 |
|
92 |
| -## Share Updates via LAN Cache Proxy |
93 |
| - |
94 |
| -`pacman-backup` can also emulate a local Cache Proxy for other pacman clients. |
95 |
| -If `pacman-backup serve` is running on the machine with internet connection, it |
96 |
| -can be used for `pacman` directly. |
97 |
| - |
98 |
| -Note that if the packages don't exist, they will appear in the logs but aren't downloaded |
99 |
| -directly; and that partial upgrades are not officially supported by Arch Linux. |
100 | 55 |
|
101 |
| -In the below example, the machine with internet connection has the IP `192.168.0.10`. |
102 |
| -Replace the IP with the correct one that matches your setup. If in doubt, use `ip` or `ifconfig`. |
103 |
| - |
104 |
| -**Step 1**: |
105 |
| - |
106 |
| -On the machine with internet connection, connect the LAN cable (and internet connection). |
107 |
| - |
108 |
| -Use `pacman-backup serve` to start a pacman server that can be used by other pacman clients. |
| 56 | +## Manual Export and Import of Database Files and Package Cache |
109 | 57 |
|
| 58 | +If you don't trust automated upgrades and want to use `pacman` directly, that's fine. You |
| 59 | +can do so by using `export` on the machine with internet connection and `import` on the |
| 60 | +machine without internet connection. |
110 | 61 |
|
111 | 62 | ```bash
|
112 | 63 | # Machine with internet connection
|
| 64 | +sudo pacman -Syuw; |
| 65 | +pacman-backup export /run/media/$USER/usb-drive; |
| 66 | +sync; |
113 | 67 |
|
114 |
| -sudo pacman -Sy; |
115 |
| -sudo pacman -Suw; |
116 |
| - |
117 |
| -pacman-backup serve; |
118 |
| -``` |
119 |
| - |
120 |
| -**Step 2**: |
121 |
| - |
122 |
| -Modify the `/etc/pacman.d/mirrorlist` to have as a first entry the following line: |
123 |
| - |
124 |
| -```conf |
125 |
| -# Machine without internet connection |
126 |
| -# Pacman Mirrorlist for local server |
127 |
| -
|
128 |
| -Server = http://192.168.0.10:15678 |
| 68 | +# Unmount the USB drive and sneak/walk to other machine |
129 | 69 | ```
|
130 | 70 |
|
131 |
| -Use `pacman -Sy` and `pacman -Su` to update from the Cache Proxy. |
132 |
| - |
133 | 71 | ```bash
|
134 | 72 | # Machine without internet connection
|
| 73 | +sudo pacman-backup import /run/media/$USER/usb-drive; |
| 74 | +sync; |
135 | 75 |
|
136 |
| -sudo pacman -Sy; |
137 |
| -sudo pacman -Su; # or use -Suw |
138 |
| -``` |
139 |
| - |
140 |
| - |
141 |
| -## Advanced Usage |
142 |
| - |
143 |
| -### Available CLI parameters |
144 |
| - |
145 |
| -The `pacman-backup` script tries to identify parameters dynamically, which means that |
146 |
| -they do not have to be written in a specific order. However, to avoid confusion, the |
147 |
| -parameters are detected in different ways; and that is documented here: |
148 |
| - |
149 |
| -- `ACTION` can be either of `archive`, `cleanup`, `download`, `serve`, or `upgrade`. Defaulted with `null` (and shows help). |
150 |
| -- `FOLDER` has to start with `/`. Defaulted with `null` (and uses `/var/cache/pacman/pkg` and `/var/lib/pacman/sync`). |
151 |
| -- `MIRROR` has to start with `https://` and contain the full `mirrorlist` syntaxed URL. Supported variables are `$arch` and `$repo`. Defaulted with `https://arch.eckner.net/os/$arch`. |
152 |
| -- `SERVER` has to be an `IPv4` separated by `.` or an `IPv6` separated by `:`. Defaulted with `null`. |
153 |
| -- `SERVER` can optionally be a `hostname`. If it is a `hostname`, make sure it's setup in the `/etc/hosts` file. |
154 |
| - |
155 |
| -Full example (which won't make sense but is parsed correctly): |
156 |
| - |
157 |
| -```bash |
158 |
| -# IMPORTANT: MIRROR string needs to be escaped, otherwise bash will try to replace it. |
159 |
| - |
160 |
| -pacman-backup download /run/media/cookiengineer/my-usb-drive "https://my.own.mirror/archlinux/\$repo/os/\$arch" 192.168.0.123; |
161 |
| - |
162 |
| -# :: pacmab-backup download |
163 |
| -# -> FOLDER: "/run/media/cookiengineer/my-usb-drive" |
164 |
| -# -> MIRROR: "https://my.own/mirror/archlinux/$repo/os/$arch" |
165 |
| -# -> SERVER: "192.168.0.123" |
166 |
| -# -> USER: "cookiengineer" |
167 |
| -``` |
168 |
| - |
169 |
| -### archive |
170 |
| - |
171 |
| -`archive` allows to backup everything to a specified folder. It copies the files from |
172 |
| -`/var/cache/pacman/pkg` and `/var/lib/pacman/sync` into `$FOLDER/pkgs` and `$FOLDER/sync`. |
173 |
| - |
174 |
| -```bash |
175 |
| -# copy local packages to /target/folder/pkgs |
176 |
| -# copy local database to /target/folder/sync |
177 |
| - |
178 |
| -pacman-backup archive /target/folder; |
179 |
| -``` |
180 |
| - |
181 |
| -### cleanup |
182 |
| - |
183 |
| -`cleanup` allows to cleanup the package cache in a way that only the latest version of |
184 |
| -each package is kept (for each architecture). |
185 |
| - |
186 |
| -If no folder is specified, it will clean up `/var/cache/pacman/pkg`. |
187 |
| -If a folder is specified, it will clean up `$FOLDER/pkgs`. |
188 |
| - |
189 |
| -```bash |
190 |
| -# cleanup /var/cache/pacman/pkg |
191 |
| - |
192 |
| -sudo pacman-backup cleanup; |
193 |
| -``` |
194 |
| - |
195 |
| -```bash |
196 |
| -# cleanup /target/folder/pkgs |
197 |
| - |
198 |
| -pacman-backup cleanup /target/folder; |
199 |
| -``` |
200 |
| - |
201 |
| -### download |
202 |
| - |
203 |
| -`download` allows to download packages from a `pacman-backup serve` based server. |
204 |
| - |
205 |
| -If no folder and a server is specified, it will run `pacman -Sy` in advance and download to `/var/cache/pacman/pkg`. |
206 |
| -If a folder and a server is specified, it will run `pacman -Sy` in advance and download to `$FOLDER/pkgs`. |
207 |
| - |
208 |
| -If no folder and no server is specified, it will generate a URL list of packages |
209 |
| -that can be copy/pasted into a download manager of choice (e.g. uGet or jdownloader). |
210 |
| - |
211 |
| -```bash |
212 |
| -# download packages to /var/cache/pacman/pkg |
213 |
| -# download database to /var/lib/pacman/sync |
214 |
| - |
215 |
| -sudo pacman-backup download 1.3.3.7; |
216 |
| -``` |
217 |
| - |
218 |
| -```bash |
219 |
| -# download packages to /target/folder/pkgs |
220 |
| -# download database to /target/folder/sync |
221 |
| - |
222 |
| -pacman-backup download 1.3.3.7 /target/folder; |
223 |
| -``` |
224 |
| - |
225 |
| -```bash |
226 |
| -# generate HTTP/S URL list for packages that need downloading |
227 |
| - |
228 |
| -pacman-backup download; |
229 |
| -``` |
230 |
| - |
231 |
| -### serve |
232 |
| - |
233 |
| -`serve` allows to start a `pacman` server that can be used as a local mirror. |
234 |
| - |
235 |
| -If no folder is specified, it will serve from `/var/cache/pacman/pkg` and `/var/lib/pacman/sync`. |
236 |
| -If a folder is specified, it will serve from `$FOLDER/pkgs` and `$FOLDER/sync`. |
237 |
| - |
238 |
| -```bash |
239 |
| -# serve packages from /var/cache/pacman/pkg |
240 |
| -# serve database from /var/lib/pacman/sync |
241 |
| - |
242 |
| -pacman-backup serve; |
243 |
| -``` |
244 |
| - |
245 |
| -```bash |
246 |
| -# serve packages from /source/folder/pkgs |
247 |
| -# serve database from /source/folder/sync |
248 |
| - |
249 |
| -pacman-backup serve /source/folder; |
250 |
| -``` |
251 |
| - |
252 |
| -### upgrade |
253 |
| - |
254 |
| -`upgrade` allows to generate an executable `pacman` command that uses the specified |
255 |
| -cache folder as a package source by leveraging the `--cachedir` parameter. |
256 |
| - |
257 |
| -If no folder is specified, it will upgrade from `/var/cache/pacman/pkg`. |
258 |
| -If a folder is specified, it will upgrade from `$FOLDER/pkgs`. |
259 |
| - |
260 |
| -```bash |
261 |
| -# generate upgrade command via packages from /var/cache/pacman/pkg |
262 |
| - |
263 |
| -pacman-backup upgrade; |
264 |
| -``` |
265 |
| - |
266 |
| -```bash |
267 |
| -# generate upgrade command via packages from /source/folder/pkgs |
268 |
| - |
269 |
| -pacman-backup upgrade /source/folder; |
| 76 | +sudo pacman -Su; |
270 | 77 | ```
|
271 | 78 |
|
272 |
| -### upgrade (Partial Upgrades) |
273 |
| - |
274 |
| -`upgrade` also prints out a command for missing packages that need downloading. |
275 |
| - |
276 |
| -In the scenario that the local database says that more packages need to be downloaded |
277 |
| -to update everything, it will output an additional command that is prepared to let |
278 |
| -`pacman` download the packages to the specified folder. |
279 | 79 |
|
280 |
| -This is helpful in the scenario that the "offline machine" has more packages installed |
281 |
| -than the "online machine" (so that more packages need to be downloaded to fully |
282 |
| -upgrade the "offline machine"). |
| 80 | +# License |
283 | 81 |
|
284 |
| -Then you can simply copy/paste the generated command to a text file and execute it |
285 |
| -next time you're online - in order to automatically download everything that's |
286 |
| -required for the "offline machine". |
287 |
| - |
288 |
| -```bash |
289 |
| -# Example output for partial upgrade scenario |
290 |
| -# (executed on machine without internet connection) |
291 |
| - |
292 |
| -pacman-backup upgrade 1.3.3.7; |
293 |
| - |
294 |
| -# :: Use this to install upgrades from cache: |
295 |
| -# (...) pacman -U command (...) |
296 |
| - |
297 |
| -# :: Use this to download upgrades into cache: |
298 |
| -# (...) pacman -Sw --cachedir command (...) |
299 |
| -``` |
| 82 | +GPL3 |
0 commit comments