]>
apps.delaporte.us Git - dotfiles.git/blob - invoke/upgrade-linux/tasks.py
1 from invoke
import task
3 from datetime
import datetime
as dt
6 HOME
= os
.path
.expanduser('~')
7 TODAY
= dt
.now().strftime('%Y.%m.%d')
8 DOTFILES
=f
'{HOME}/dotfiles'
12 def backup_package_list(c
):
13 c
.run(f
'dpkg --get-selections > {HOME}/backup/packages.{TODAY}.dpkg')
16 def show_disk_space(c
):
17 print("Do we have at least 5G of free space?")
21 def backup_sources(c
):
22 c
.run(f
'cp /etc/apt/sources.list {HOME}/backup/sources.list.{TODAY}.backup')
28 print("Use --prompt-for-sudo")
29 c
.run(f
'sudo tar -czf {HOME}/backup/etc.backup.{TODAY}.tar.gz /etc')
31 c
.run(f
'sudo chown {login}:{login} {HOME}/backup/etc.backup.{TODAY}.tar.gz')
35 print("- [ ] Review the output of `invoke review-backups`")
36 print("- [ ] Verify that {HOME}/backup is backed up on a separate device.")
37 print("- [ ] Verify we have at least 5G of free space. (`invoke show-disk-space`)")
40 def review_backups(c
):
41 print('Lines in dpkg backup:')
42 c
.run(f
'cat {HOME}/backup/*.dpkg | wc -l')
43 print('Files in /etc backup:')
44 c
.run(f
'tar tf {HOME}/backup/etc.backup.*.tar.gz | wc -l')
45 print('Ensure sources are backed up:')
46 c
.run(f
'tar tf {HOME}/backup/etc.backup.*.tar.gz | grep etc/apt/sources')
47 c
.run(f
'ls -al --block-size=M {HOME}/backup')
52 backup_package_list(c
)
53 backup_sources_list(c
)