Para encontrar @home
e @
data recente
comm -12 <(grep -oP '@home-\K[0-9-]*' bkup.list | sort) \
<(grep -oP '@-\K[0-9-]*' bkup.list | sort) |
tail -n 1
Eu gostaria de modificar meu script de backup para que ele determine automaticamente a data correta para o backup mais recente. Atualmente, ele apenas exibe a lista de arquivos na minha unidade interna e externa e eu insiro uma data manualmente.
Aqui está como uma sessão típica seria. Minha entrada está entre aspas.
$ sudo backup.sh
/dev/mapper/cr-root:
@ @-2016-07-27 @home-2016-06-24 @home-2016-08-01
@-2016-06-19 @-2016-07-29 @home-2016-06-27 @home-2016-08-04
@-2016-06-24 @-2016-08-01 @home-2016-07-06 @home-2016-08-07
@-2016-06-27 @-2016-08-04 @home-2016-07-09 @home-2016-08-13
@-2016-07-06 @-2016-08-07 @home-2016-07-11 @music
@-2016-07-09 @-2016-08-13 @home-2016-07-15 @music-2016-06-27
@-2016-07-11 @-2016-08-19 @home-2016-07-22 @music-2016-07-06
@-2016-07-15 @-clean @home-2016-07-24 @music-2016-07-09
@-2016-07-22 @home @home-2016-07-27
@-2016-07-24 @home-2016-06-19 @home-2016-07-29
-----------------------------------------------------------------------
/dev/sdb1:
@-2015-10-17 @-2016-07-27 @home-2015-12-30
@-2015-10-24 @-2016-07-29 @home-2016-01-01
@-2015-10-30 @-2016-08-01 @home-2016-01-03
@-2015-11-10 @-2016-08-04 @home-2016-01-07
@-2015-11-11 @-2016-08-07 @home-2016-01-10
@-2015-11-12 @-2016-08-13 @home-2016-01-12
@-2015-11-20 @-2016-08-19 @home-2016-01-14
@-2015-11-21 @-clean @home-2016-01-21
@-2015-11-25 @Dropbox-2015-10-17 @home-2016-01-26
@-2015-12-01 @Dropbox-2015-10-24 @home-2016-01-28
@-2015-12-10 @Dropbox-2015-10-30 @home-2016-02-13
@-2015-12-14 @Dropbox-2015-11-10 @home-2016-02-15
@-2015-12-15 @Dropbox-2015-11-20 @home-2016-02-17
@-2015-12-19 @Dropbox-2015-11-25 @home-2016-02-18
@-2015-12-20 @Dropbox-2015-12-01 @home-2016-02-26
@-2015-12-30 @Dropbox-2015-12-10 @home-2016-03-01
@-2016-01-01 @Dropbox-2015-12-14 @home-2016-03-04
@-2016-01-03 @Dropbox-2015-12-19 @home-2016-03-07
@-2016-01-07 @Dropbox-2015-12-20 @home-2016-03-12
@-2016-01-10 @Dropbox-2015-12-30 @home-2016-03-18
@-2016-01-12 @Dropbox-2016-01-01 @home-2016-03-28
@-2016-01-14 @Dropbox-2016-01-03 @home-2016-03-29
@-2016-01-21 @Dropbox-2016-01-07 @home-2016-04-05
@-2016-01-26 @Dropbox-2016-01-10 @home-2016-04-06
@-2016-01-28 @Dropbox-2016-01-12 @home-2016-04-09
@-2016-02-04 @Dropbox-2016-01-14 @home-2016-04-15
@-2016-02-05 @Dropbox-2016-01-21 @home-2016-04-18
@-2016-02-06 @Dropbox-2016-01-26 @home-2016-04-22
@-2016-02-13 @Dropbox-2016-01-28 @home-2016-05-01
@-2016-02-15 @Dropbox-2016-02-04 @home-2016-05-06
@-2016-02-17 @Dropbox-2016-02-05 @home-2016-05-08
@-2016-02-18 @Dropbox-2016-02-06 @home-2016-05-24
@-2016-02-26 @Dropbox-2016-02-13 @home-2016-06-04
@-2016-03-01 @Dropbox-2016-02-15 @home-2016-06-08
@-2016-03-04 @Dropbox-2016-02-17 @home-2016-06-14
@-2016-03-07 @Dropbox-2016-02-18 @home-2016-06-17
@-2016-03-12 @Dropbox-2016-02-26 @home-2016-06-19
@-2016-03-18 @Dropbox-2016-03-01 @home-2016-06-24
@-2016-03-28 @Dropbox-2016-03-04 @home-2016-06-27
@-2016-03-29 @Dropbox-2016-03-07 @home-2016-07-06
@-2016-04-05 @Dropbox-2016-03-12 @home-2016-07-09
@-2016-04-06 @Dropbox-2016-03-18 @home-2016-07-11
@-2016-04-09 @Dropbox-2016-03-28 @home-2016-07-15
@-2016-04-15 @Dropbox-2016-03-29 @home-2016-07-22
@-2016-04-18 @Dropbox-2016-04-05 @home-2016-07-24
@-2016-04-22 @Dropbox-2016-04-06 @home-2016-07-27
@-2016-05-01 @Dropbox-2016-04-09 @home-2016-07-29
@-2016-05-06 @Dropbox-2016-04-15 @home-2016-08-01
@-2016-05-08 @Dropbox-2016-04-18 @home-2016-08-04
@-2016-05-24 @Dropbox-2016-04-22 @home-2016-08-07
@-2016-06-04 @home-2015-10-17 @home-2016-08-13
@-2016-06-08 @home-2015-10-24
@-2016-06-14 @home-2015-11-10
@-2016-06-17 @home-2015-11-11
@-2016-06-19 @home-2015-11-12
@-2016-06-24 @home-2015-11-20
@-2016-06-27 @home-2015-11-21
@-2016-07-06 @home-2015-11-25
@-2016-07-09 @home-2015-12-01
@-2016-07-11 @home-2015-12-10
@-2016-07-15 @home-2015-12-14
@-2016-07-22 @home-2015-12-19
@-2016-07-24 @home-2015-12-20
-----------------------------------------------------------------------
Backup @ [y/n]? "y"
Backup @home [y/n]? "y"
Backup @music [y/n]? "n"
Date of previous version: "2016-08-13"
...
Para um determinado subvolume (como @
ou @home
), quero encontrar o instantâneo datado mais recente que ambos têm em comum. Neste caso, estou procurando por @-2016-08-13
e @home-2016-08-13
, respectivamente. Eu posso usar find
para enviar todos os arquivos do formulário @-date
, por exemplo, mas preciso comparar as datas e encontrar as mais recentes que ambas as listas têm. Eu sei que um regex sozinho provavelmente não pode fazer isso, mas eu não sei o que vai acontecer.
Eu quero encontrar a data comum mais recente em uma lista de arquivos sem usar timestamps. Por exemplo, dadas essas listas ...
@-2016-07-24 @-2016-08-01 @-2016-08-13 @-2016-08-19
e
@-2016-07-24 @-2016-08-01 @-2016-08-13
Eu quero encontrar o arquivo comum com a data mais alta, que é @-2016-08-13
neste caso. Eu preferiria usar utilitários UNIX integrados para fazer isso.
Tags backup find date regular-expression