Script started on 2024-08-07 11:33:56+00:00 [TERM="xterm-256color" TTY="/dev/pts/0" COLUMNS="133" LINES="37"]
]0;ubuntu@bastion: ~[01;32mubuntu@bastion[00m:[01;34m~[00m$ cd /etc/records/
]0;ubuntu@bastion: /etc/records[01;32mubuntu@bastion[00m:[01;34m/etc/records[00m$ ls
ak_cmd_2024-08-07_11-33-45.log   ubuntu_cmd_2024-08-07_11-33-39.log  ubuntu_time_2024-08-07_11-33-39.log
ak_time_2024-08-07_11-33-45.log  ubuntu_cmd_2024-08-07_11-33-56.log  ubuntu_time_2024-08-07_11-33-56.log
]0;ubuntu@bastion: /etc/records[01;32mubuntu@bastion[00m:[01;34m/etc/records[00m$ sudo mkdir -p "$NEW_FOLDER"[K[K[K[K[K[K[K[K[K[K[K[K[K[K[K[K[K[K[K[K[K[K[K[K[K[K[Kmkdir -p /etc/records/[K[Ks_new
mkdir: cannot create directory ‘/etc/records_new’: Permission denied
]0;ubuntu@bastion: /etc/records[01;32mubuntu@bastion[00m:[01;34m/etc/records[00m$ mkdir -p /etc/records_new[1@s[1@u[1@d[1@o[1@ 
]0;ubuntu@bastion: /etc/records[01;32mubuntu@bastion[00m:[01;34m/etc/records[00m$ sudo cp -r "$LOG_FOLDER"/* "$NEW_FOLDER"^C
]0;ubuntu@bastion: /etc/records[01;32mubuntu@bastion[00m:[01;34m/etc/records[00m$ sudo cp -r /etc/records /etc/records
records/     records_new/ 
]0;ubuntu@bastion: /etc/records[01;32mubuntu@bastion[00m:[01;34m/etc/records[00m$ sudo cp -r /etc/records /etc/records_new/
]0;ubuntu@bastion: /etc/records[01;32mubuntu@bastion[00m:[01;34m/etc/records[00m$ cd ..
]0;ubuntu@bastion: /etc[01;32mubuntu@bastion[00m:[01;34m/etc[00m$ ls
[0m[01;34mNetworkManager[0m                 [01;34mdbus-1[0m              [01;34minitramfs-tools[0m  mime.types               [01;34mppp[0m            [01;34msos[0m
[01;34mPackageKit[0m                     [01;34mdconf[0m               inputrc          mke2fs.conf              profile        [01;34mssh[0m
[01;34mX11[0m                            debconf.conf        [01;34miproute2[0m         [01;34mmodprobe.d[0m               [01;34mprofile.d[0m      [01;34mssl[0m
adduser.conf                   debian_version      [01;34miscsi[0m            modules                  protocols      subgid
[01;34malternatives[0m                   [01;34mdefault[0m             issue            [01;34mmodules-load.d[0m           [01;34mpython3[0m        subgid-
[01;34mapparmor[0m                       deluser.conf        issue.net        mongod.conf              [01;34mpython3.8[0m      subuid
[01;34mapparmor.d[0m                     [01;34mdepmod.d[0m            [01;34mkernel[0m           [01;36mmtab[0m                     [01;34mrc0.d[0m          subuid-
[01;34mapport[0m                         [01;34mdhcp[0m                kernel-img.conf  [01;34mmultipath[0m                [01;34mrc1.d[0m          sudoers
[01;34mapt[0m                            [01;34mdpkg[0m                [01;34mlandscape[0m        multipath.conf           [01;34mrc2.d[0m          [01;34msudoers.d[0m
at.deny                        e2scrub.conf        ld.so.cache      nanorc                   [01;34mrc3.d[0m          sysctl.conf
bash.bashrc                    ec2_version         ld.so.conf       [01;34mnetplan[0m                  [01;34mrc4.d[0m          [01;34msysctl.d[0m
bash_completion                environment         [01;34mld.so.conf.d[0m     [01;34mnetwork[0m                  [01;34mrc5.d[0m          [01;34msysstat[0m
[01;34mbash_completion.d[0m              ethertypes          [01;34mldap[0m             [01;34mnetworkd-dispatcher[0m      [01;34mrc6.d[0m          [01;34msystemd[0m
bindresvport.blacklist         [01;34mfonts[0m               legal            networks                 [01;34mrcS.d[0m          [01;34mterminfo[0m
[01;34mbinfmt.d[0m                       fstab               libaudit.conf    [01;34mnewt[0m                     [30;42mrecords[0m        timezone
boto.cfg                       fuse.conf           locale.alias     nsswitch.conf            [01;34mrecords_new[0m    [01;34mtmpfiles.d[0m
[01;34mbyobu[0m                          gai.conf            locale.gen       [01;34mnvme[0m                     [01;34mredis[0m          [01;34mubuntu-advantage[0m
[01;34mca-certificates[0m                google_instance_id  [01;36mlocaltime[0m        [01;34mopt[0m                      [01;36mresolv.conf[0m    ucf.conf
ca-certificates.conf           [01;34mgroff[0m               [01;34mlogcheck[0m         [01;36mos-release[0m               [01;36mrmt[0m            [01;34mudev[0m
ca-certificates.conf.dpkg-old  group               login.defs       overlayroot.conf         rpc            [01;34mufw[0m
[01;34mcalendar[0m                       group-              logrotate.conf   overlayroot.local.conf   rsyslog.conf   [01;34mupdate-manager[0m
[01;34mchrony[0m                         [01;34mgrub.d[0m              [01;34mlogrotate.d[0m      pam.conf                 [01;34mrsyslog.d[0m      [01;34mupdate-motd.d[0m
[01;34mcloud[0m                          gshadow             lsb-release      [01;34mpam.d[0m                    screenrc       [01;34mupdate-notifier[0m
[01;34mconsole-setup[0m                  gshadow-            ltrace.conf      passwd                   [01;34msecurity[0m       [01;34mvim[0m
[01;34mcron.d[0m                         [01;34mgss[0m                 [01;34mlvm[0m              passwd-                  [01;34mselinux[0m        [01;34mvmware-tools[0m
[01;34mcron.daily[0m                     hdparm.conf         machine-id       [01;34mperl[0m                     [01;34msensors.d[0m      [01;36mvtrgb[0m
[01;34mcron.hourly[0m                    host.conf           magic            [01;34mpm[0m                       sensors3.conf  wgetrc
[01;34mcron.monthly[0m                   hostname            magic.mime       [01;34mpolkit-1[0m                 services       xattr.conf
[01;34mcron.weekly[0m                    hosts               mailcap          [01;34mpollinate[0m                shadow         [01;34mxdg[0m
crontab                        hosts.allow         mailcap.order    popularity-contest.conf  shadow-        zsh_command_not_found
[01;34mcryptsetup-initramfs[0m           hosts.deny          manpath.config   [01;34mpostgresql[0m               shells
crypttab                       [01;34minit.d[0m              [01;34mmdadm[0m            [01;34mpostgresql-common[0m        [01;34mskel[0m
]0;ubuntu@bastion: /etc[01;32mubuntu@bastion[00m:[01;34m/etc[00m$ cat [K[K[K[Kcd records
]0;ubuntu@bastion: /etc/records[01;32mubuntu@bastion[00m:[01;34m/etc/records[00m$ LATEST_FILES=$(sudo ls -1t "${LOG_FOLDER}${USER}_*" | head -n 2)[C[1P[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[1P[C
]0;ubuntu@bastion: /etc/records[01;32mubuntu@bastion[00m:[01;34m/etc/records[00m$ echo #LOG[K[K[K[K$LOGNAME [K[K[K[K[K[KG_F[K[K[K[K[K[K[K[K[K[K[KLATEST_FILES=$(sudo ls -1t ${LOG_FOLDER}${USER}_* | head -n 2)[1P[1P[1P[1P[1P[1P[1P[1P[1P[1P[1P[1P[1P[C[C[C[C[C[C[C[1P[1P[1P[1P[1P[1P[1@w[1@h[1@o[1@a[1@m[1@i[C[1@/[1@e[1@t[1@c[1@/[1@r[1@e
records/     records_new/ redis/       resolv.conf  
]0;ubuntu@bastion: /etc/records[01;32mubuntu@bastion[00m:[01;34m/etc/records[00m$ LATEST_FILES=$(sudo ls -1t /etc/re$whoami_* | head -n 2)[1@c[4@ords[1@/
]0;ubuntu@bastion: /etc/records[01;32mubuntu@bastion[00m:[01;34m/etc/records[00m$ echo $LA
$LANG          $LATEST_FILES  
]0;ubuntu@bastion: /etc/records[01;32mubuntu@bastion[00m:[01;34m/etc/records[00m$ echo $LATEST_FILES 
/etc/records/ubuntu_time_2024-08-07_11-33-56.log /etc/records/ubuntu_cmd_2024-08-07_11-33-56.log
]0;ubuntu@bastion: /etc/records[01;32mubuntu@bastion[00m:[01;34m/etc/records[00m$ FILES_TO_KEEP=$(echo "$LATEST_FILES" | xargs -n 1 basename | tr '\n' ' ')
]0;ubuntu@bastion: /etc/records[01;32mubuntu@bastion[00m:[01;34m/etc/records[00m$ echo $FILES_TO_KEEP 
ubuntu_time_2024-08-07_11-33-56.log ubuntu_cmd_2024-08-07_11-33-56.log
]0;ubuntu@bastion: /etc/records[01;32mubuntu@bastion[00m:[01;34m/etc/records[00m$ for FILE in $(sudo ls "$LOG_FOLDER"); do
>   if ! echo "$FILES_TO_KEEP" | grep -qw "$FILE"; then
>     sudo rm -f "$LOG_FOLDER/$FILE"
>   fi
> done
ls: cannot access '': No such file or directory
]0;ubuntu@bastion: /etc/records[01;32mubuntu@bastion[00m:[01;34m/etc/records[00m$ for FILE in $(sudo ls "$LOG_FOLDER"); do   if ! echo "$FILES_TO_KEEP" | grep -qw "$FILE"; then     sudo rm -f "$LOG_FOLDER/$FILE";   fi; done[A[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C); do   if ! echo "$FILES_TO_KEEP" | grep -qw "$FILE"; then     sudo rm[1P[A]0;ubuntu@bastion: /etc/records[01;32mubuntu@bastion[00m:[01;34m/etc/records[00m$ [C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C); do   if ! echo "$FILES_TO_KEEP" | grep -qw "$FILE"; then     sudo rm [1P[A]0;ubuntu@bastion: /etc/records[01;32mubuntu@bastion[00m:[01;34m/etc/records[00m$ [C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C); do   if ! echo "$FILES_TO_KEEP" | grep -qw "$FILE"; then     sudo rm -[1P[A]0;ubuntu@bastion: /etc/records[01;32mubuntu@bastion[00m:[01;34m/etc/records[00m$ [C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C); do   if ! echo "$FILES_TO_KEEP" | grep -qw "$FILE"; then     sudo rm -f[1P[A]0;ubuntu@bastion: /etc/records[01;32mubuntu@bastion[00m:[01;34m/etc/records[00m$ [C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C); do   if ! echo "$FILES_TO_KEEP" | grep -qw "$FILE"; then     sudo rm -f [1P[A]0;ubuntu@bastion: /etc/records[01;32mubuntu@bastion[00m:[01;34m/etc/records[00m$ [C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C); do   if ! echo "$FILES_TO_KEEP" | grep -qw "$FILE"; then     sudo rm -f "[1P[A]0;ubuntu@bastion: /etc/records[01;32mubuntu@bastion[00m:[01;34m/etc/records[00m$ [C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C); do   if ! echo "$FILES_TO_KEEP" | grep -qw "$FILE"; then     sudo rm -f "$[1P[A]0;ubuntu@bastion: /etc/records[01;32mubuntu@bastion[00m:[01;34m/etc/records[00m$ [C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C); do   if ! echo "$FILES_TO_KEEP" | grep -qw "$FILE"; then     sudo rm -f "$L[1P[A]0;ubuntu@bastion: /etc/records[01;32mubuntu@bastion[00m:[01;34m/etc/records[00m$ [C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C); do   if ! echo "$FILES_TO_KEEP" | grep -qw "$FILE"; then     sudo rm -f "$LO[1P[A]0;ubuntu@bastion: /etc/records[01;32mubuntu@bastion[00m:[01;34m/etc/records[00m$ [C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C); do   if ! echo "$FILES_TO_KEEP" | grep -qw "$FILE"; then     sudo rm -f "$LOG[1P[A]0;ubuntu@bastion: /etc/records[01;32mubuntu@bastion[00m:[01;34m/etc/records[00m$ [C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C); do   if ! echo "$FILES_TO_KEEP" | grep -qw "$FILE"; then     sudo rm -f "$LOG_[1P[A]0;ubuntu@bastion: /etc/records[01;32mubuntu@bastion[00m:[01;34m/etc/records[00m$ [C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C); do   if ! echo "$FILES_TO_KEEP" | grep -qw "$FILE"; then     sudo rm -f "$LOG_F[1P[A]0;ubuntu@bastion: /etc/records[01;32mubuntu@bastion[00m:[01;34m/etc/records[00m$ [C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C); do   if ! echo "$FILES_TO_KEEP" | grep -qw "$FILE"; then     sudo rm -f "$LOG_FO[1P[A]0;ubuntu@bastion: /etc/records[01;32mubuntu@bastion[00m:[01;34m/etc/records[00m$ [C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C/); do   if ! echo "$FILES_TO_KEEP" | grep -qw "$FILE"; then     sudo rm -f "$LOG_F[1@O[A]0;ubuntu@bastion: /etc/records[01;32mubuntu@bastion[00m:[01;34m/etc/records[00m$ [C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[Ce); do   if ! echo "$FILES_TO_KEEP" | grep -qw "$FILE"; then     sudo rm -f "$LOG_[1@F[A]0;ubuntu@bastion: /etc/records[01;32mubuntu@bastion[00m:[01;34m/etc/records[00m$ [C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[Ct); do   if ! echo "$FILES_TO_KEEP" | grep -qw "$FILE"; then     sudo rm -f "$LOG[1@_[A]0;ubuntu@bastion: /etc/records[01;32mubuntu@bastion[00m:[01;34m/etc/records[00m$ [C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[Cc); do   if ! echo "$FILES_TO_KEEP" | grep -qw "$FILE"; then     sudo rm -f "$LO[1@G[A]0;ubuntu@bastion: /etc/records[01;32mubuntu@bastion[00m:[01;34m/etc/records[00m$ [C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C/); do   if ! echo "$FILES_TO_KEEP" | grep -qw "$FILE"; then     sudo rm -f "$L[1@O[A]0;ubuntu@bastion: /etc/records[01;32mubuntu@bastion[00m:[01;34m/etc/records[00m$ [C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[Cr); do   if ! echo "$FILES_TO_KEEP" | grep -qw "$FILE"; then     sudo rm -f "$[1@L[A]0;ubuntu@bastion: /etc/records[01;32mubuntu@bastion[00m:[01;34m/etc/records[00m$ [C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[Ce); do   if ! echo "$FILES_TO_KEEP" | grep -qw "$FILE"; then     sudo rm -f "[1@$[A]0;ubuntu@bastion: /etc/records[01;32mubuntu@bastion[00m:[01;34m/etc/records[00m$ [C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[Cc); do   if ! echo "$FILES_TO_KEEP" | grep -qw "$FILE"; then     sudo rm -f [1@"[A]0;ubuntu@bastion: /etc/records[01;32mubuntu@bastion[00m:[01;34m/etc/records[00m$ [C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[Co); do   if ! echo "$FILES_TO_KEEP" | grep -qw "$FILE"; then     sudo rm -f[1@ [A]0;ubuntu@bastion: /etc/records[01;32mubuntu@bastion[00m:[01;34m/etc/records[00m$ [C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[Cr); do   if ! echo "$FILES_TO_KEEP" | grep -qw "$FILE"; then     sudo rm -[1@f[A]0;ubuntu@bastion: /etc/records[01;32mubuntu@bastion[00m:[01;34m/etc/records[00m$ [C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[Cd); do   if ! echo "$FILES_TO_KEEP" | grep -qw "$FILE"; then     sudo rm [1@-[A]0;ubuntu@bastion: /etc/records[01;32mubuntu@bastion[00m:[01;34m/etc/records[00m$ [C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[Cs); do   if ! echo "$FILES_TO_KEEP" | grep -qw "$FILE"; then     sudo rm[1@ [A]0;ubuntu@bastion: /etc/records[01;32mubuntu@bastion[00m:[01;34m/etc/records[00m$ [C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C

]0;ubuntu@bastion: /etc/records[01;32mubuntu@bastion[00m:[01;34m/etc/records[00m$ ls
ak_cmd_2024-08-07_11-33-45.log   ubuntu_cmd_2024-08-07_11-33-39.log  ubuntu_time_2024-08-07_11-33-39.log
ak_time_2024-08-07_11-33-45.log  ubuntu_cmd_2024-08-07_11-33-56.log  ubuntu_time_2024-08-07_11-33-56.log
]0;ubuntu@bastion: /etc/records[01;32mubuntu@bastion[00m:[01;34m/etc/records[00m$ lsfor FILE in $(sudo ls /etc/records); do   if ! echo "$FILES_TO_KEEP" | grep -qw "$FILE"; then     sudo rm -f "$LOG_FOLDER/$FILE";   fi; done[C[1P[1P[1P[1P[1P[1P[1P[1P[1P[1P[1P[1P[C[1@/[1@e[1@t[1@c[C[1@/[1@r[1@e[1@c[4@ords[C[C[C[C[C[C[C[1P
]0;ubuntu@bastion: /etc/records[01;32mubuntu@bastion[00m:[01;34m/etc/records[00m$ ls
ubuntu_cmd_2024-08-07_11-33-56.log  ubuntu_time_2024-08-07_11-33-56.log
]0;ubuntu@bastion: /etc/records[01;32mubuntu@bastion[00m:[01;34m/etc/records[00m$ gcloud auth activate-service-account --key-file="$SERVICE_ACCOUNT_KEY"[C[C[K[K[K[K[K[K[K[K[K[K[K[K[K[K[K[K[K[K[K[K[K[K/home/ubuntu/bin/servo[Kice.json
Activated service account credentials for: [logbucket@nitrox-415207.iam.gserviceaccount.com]
]0;ubuntu@bastion: /etc/records[01;32mubuntu@bastion[00m:[01;34m/etc/records[00m$ sudo gsutil cp -r "$NEW_FOLDER" "$DESTINATION"^C
]0;ubuntu@bastion: /etc/records[01;32mubuntu@bastion[00m:[01;34m/etc/records[00m$ gcloud auth activate-service-account --key-file=/home/ubuntu/bin/service.json[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[Cls[Kfor FILE in $(sudo ls /etc/records); do   if ! echo "$FILES_TO_KEEP" | grep -qw "$FILE"; then     sudo rm -f /etc/records/$FILE;   fi; done[Als[K
[K[A[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[Cfor FILE in $(sudo ls /etc/records); do   if ! echo "$FILES_TO_KEEP" | grep -qw "$FILE"; then     sudo rm -f "$LOG_FOLDER/$FILE";   fi; done[A[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C"$LOG_FOLDER"); do   if ! echo "$FILES_TO_KEEP" | grep -qw "$FILE"; then     sudo r[1@m[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[Aecho $FILES_TO_KEEP [K
[K[A[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[CFILES_TO_KEEP=$(echo "$LATEST_FILES" | xargs -n 1 basename | tr '\n' ' ')[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[Cecho $LATEST_FILES [KLATEST_FILES=$(sudo ls -1t /etc/records/$whoami_* | head -n 2)${LOG_FOLDER}${USER}[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[Ccd records[Kls[Kcd ..sudo cp -r /etc/records /etc/records_new/[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[11Pmkdir -p /etc/records_newcp -r /etc/records /etc/records_new/^C
]0;ubuntu@bastion: /etc/records[01;32mubuntu@bastion[00m:[01;34m/etc/records[00m$ ls
ubuntu_cmd_2024-08-07_11-33-56.log  ubuntu_time_2024-08-07_11-33-56.log
]0;ubuntu@bastion: /etc/records[01;32mubuntu@bastion[00m:[01;34m/etc/records[00m$ cd 
]0;ubuntu@bastion: ~[01;32mubuntu@bastion[00m:[01;34m~[00m$ ls
[0m[01;34mbin[0m  [01;34msnap[0m
]0;ubuntu@bastion: ~[01;32mubuntu@bastion[00m:[01;34m~[00m$ cd [K[K[Ksudo [K[K[K[K[Kcd bin
]0;ubuntu@bastion: ~/bin[01;32mubuntu@bastion[00m:[01;34m~/bin[00m$ ls
[0m[01;32maudit.sh[0m  [01;32mcpu_and_memory.sh[0m  [01;32mlog.sh[0m  [01;32mrecordslog.sh[0m  service.json  [01;32mstart_slack.sh[0m
]0;ubuntu@bastion: ~/bin[01;32mubuntu@bastion[00m:[01;34m~/bin[00m$ sudo v [Ki recordslog.sh 
[?1049h[22;0;0t[>4;2m[?1h=[?2004h[1;37r[?12h[?12l[22;2t[22;1t[27m[23m[29m[m[H[2J[?25l[37;1H"recordslog.sh" 41L, 1205C[2;1H▽[6n[2;1H  [1;1H[>c]10;?]11;?[1;1H[34m#!/bin/bash

# Variables[m
[36mUSER[m=[35m$([m[35mwhoami[m[35m)[m [34m# or replace with your specific username if needed[m
[36mLOG_FOLDER[m=[38;5;130m"[m[31m/etc/records[m[38;5;130m"[m
[36mDATE[m=[35m$([m[35mdate +[m[38;5;130m"[m[31m%Y-%m-%d_%H-%M-%S[m[38;5;130m"[m[35m)[m
[36mNEW_FOLDER[m=[38;5;130m"[m[31m/etc/records_[m[35m$DATE[m[38;5;130m"[m
[36mBUCKET_NAME[m=[38;5;130m"[m[31mnitrologbucket[m[38;5;130m"[m
[36mDESTINATION[m=[38;5;130m"[m[31mgs://[m[35m$BUCKET_NAME[m[31m/[m[35m$DATE[m[31m/[m[38;5;130m"[m
[36mSERVICE_ACCOUNT_KEY[m=[38;5;130m"[m[31m/home/ubuntu/bin/service.json[m[38;5;130m"[m

[34m# Create a new folder with the current date and time[m
sudo [38;5;130mmkdir[m [35m-p[m [38;5;130m"[m[35m$NEW_FOLDER[m[38;5;130m"[m

[34m# Copy log file data to the new folder[m
sudo cp [35m-r[m [38;5;130m"[m[35m$LOG_FOLDER[m[38;5;130m"[m/* [38;5;130m"[m[35m$NEW_FOLDER[m[38;5;130m"[m

[34m# Get the latest two files in the log folder[m
[36mLATEST_FILES[m=[35m$([m[35msudo [m[38;5;130mls[m[35m -1t [m[35m${LOG_FOLDER}${USER}[m[35m_* [m[38;5;130m|[m[35m head -n [m[31m2[m[35m)[m

[34m# Extract filenames to keep[m
[36mFILES_TO_KEEP[m=[35m$([m[38;5;130mecho[m[31m [m[38;5;130m"[m[35m$LATEST_FILES[m[38;5;130m"[m[31m [m[38;5;130m|[m[35m xargs -n [m[31m1[m[35m basename [m[38;5;130m|[m[35m tr [m[38;5;130m'[m[31m\n[m[38;5;130m'[m[35m [m[38;5;130m'[m[31m [m[38;5;130m'[m[35m)[m

[34m# Remove all files except the latest two[m
[38;5;130mfor[m FILE [38;5;130min[m [35m$([m[35msudo [m[38;5;130mls[m[35m [m[38;5;130m"[m[35m$LOG_FOLDER[m[38;5;130m"[m[35m)[m; [38;5;130mdo
[m  [38;5;130mif ![m [38;5;130mecho[m[31m [m[38;5;130m"[m[35m$FILES_TO_KEEP[m[38;5;130m"[m[31m [m[38;5;130m|[m [38;5;130mgrep[m [35m-qw[m [38;5;130m"[m[35m$FILE[m[38;5;130m";[m [38;5;130mthen[m
    sudo [38;5;130mrm[m [38;5;130m-f[m [38;5;130m"[m[35m$LOG_FOLDER[m[31m/[m[35m$FILE[m[38;5;130m"
[m  [38;5;130mfi
done[m

[34m# Authenticate with GCP[m
gcloud auth activate-service-account [35m--key-file=[m[38;5;130m"[m[35m$SERVICE_ACCOUNT_KEY[m[38;5;130m"[m

[34m# Upload the new folder to GCP bucket[m
sudo gsutil cp [35m-r[m [38;5;130m"[m[35m$NEW_FOLDER[m[38;5;130m"[m [38;5;130m"[m[35m$DESTINATION[m[38;5;130m"[m[37;116H5,24[10CTop[5;24H[?25h[?25l[37;106H^[[5;24H[37;106H  [5;24H[37;106H^[[5;24H[37;106H  [5;24H[?25h[?25l[37;106Hd[5;24H[?25h[?25l[37;107Hd[5;24H[37;106H  [5;1H[5;36r[36;1H
[1;37r[36;1H[34m# Optionally, remove the local copy after upload[m[37;1H[K[37;116H5,1[11CTop[5;1H[?25h[?25l[37;106Hd[5;1H[?25h[?25l[37;107Hd[5;1H[37;106H  [5;1H[5;36r[36;1H
[1;37r[36;1Hsudo [38;5;130mrm[m [35m-rf[m [38;5;130m"[m[35m$NEW_FOLDER[m[38;5;130m"[m[37;116H[K[37;116H5,1[11CTop[5;1H[?25h[?25l[37;106Hd[5;1H[?25h[?25l[37;106H [5;1H[5;36r[36;1H
[1;37r[37;116H[K[37;116H5,1[11CTop[5;1H[?25h[?25l[37;106Hdd[5;1H[37;106H  [5;1H[5;36r[36;1H
[1;37r[36;1H[38;5;130mecho[m[31m [m[38;5;130m"[m[31mLog file uploaded and original file cleared, except for the latest two files.[m[38;5;130m"[m[37;116H[K[37;116H5,1[11CTop[5;1H[?25h[?25l[37;106Hd[5;1H[?25h[?25l[37;107Hd[5;1H[37;106H  [5;1H[5;36r[36;1H
[1;37r[37;116H[K[37;116H5,1[11CAll[5;1H[?25h[?25l[37;106Hd[5;1H[?25h[?25l[37;107Hd[5;1H[37;106H  [5;1H[5;36r[36;1H
[1;37r[36;1H[94m~                                                                                                                                    [m[37;116H[K[37;116H5,0-1[9CAll[5;1H[?25h[?25l[37;106Hd[5;1H[?25h[?25l[37;107Hd[5;1H[37;106H  [5;1H[5;36r[36;1H
[1;37r[36;1H[94m~                                                                                                                                    [m[37;116H[K[37;116H5,1[11CAll[5;1H[?25h[?25l[37;106Hd[5;1H[?25h[?25l[37;107Hd[5;1H[37;106H  [5;1H[5;36r[36;1H
[1;37r[36;1H[94m~                                                                                                                                    [m[37;116H[K[37;116H5,1[11CAll[5;1H[?25h[?25l[37;106Hd[5;1H[?25h[?25l[37;107Hd[5;1H[37;106H  [5;1H[5;36r[36;1H
[1;37r[36;1H[94m~                                                                                                                                    [m[37;116H[K[37;116H5,0-1[9CAll[5;1H[?25h[?25l[37;106Hd[5;1H[?25h[?25l[37;107Hd[5;1H[37;106H  [5;1H[5;36r[36;1H
[1;37r[36;1H[94m~                                                                                                                                    [m[37;116H[K[37;116H5,1[11CAll[5;1H[?25h[?25l[37;106Hd[5;1H[?25h[?25l[37;107Hd[5;1H[37;106H  [5;1H[5;36r[36;1H
[1;37r[36;1H[94m~                                                                                                                                    [m[37;116H[K[37;116H5,1[11CAll[5;1H[?25h[?25l[37;106Hd[5;1H[?25h[?25l[37;107Hd[5;1H[37;106H  [5;1H[5;36r[36;1H
[1;37r[36;1H[94m~                                                                                                                                    [m[37;116H[K[37;116H5,0-1[9CAll[5;1H[?25h[?25l[37;106Hd[5;1H[?25h[?25l[37;107Hd[5;1H[37;106H  [5;1H[5;36r[36;1H
[1;37r[36;1H[94m~                                                                                                                                    [m[37;116H[K[37;116H5,1[11CAll[5;1H[?25h[?25l[37;106Hd[5;1H[?25h[?25l[37;107Hd[5;1H[37;106H  [5;1H[5;36r[36;1H
[1;37r[36;1H[94m~                                                                                                                                    [m[37;116H[K[37;116H5,1[11CAll[5;1H[?25h[?25l[37;106Hd[5;1H[?25h[?25l[37;107Hd[5;1H[37;106H  [5;1H[5;36r[36;1H
[1;37r[36;1H[94m~                                                                                                                                    [m[37;116H[K[37;116H5,0-1[9CAll[5;1H[?25h[?25l[37;106Hd[5;1H[?25h[?25l[37;107Hd[5;1H[37;106H  [5;1H[5;36r[36;1H
[1;37r[36;1H[94m~                                                                                                                                    [m[37;116H[K[37;116H5,1[11CAll[5;1H[?25h[?25l[37;106Hd[5;1H[?25h[?25l[37;107Hd[5;1H[37;106H  [5;1H[5;36r[36;1H
[1;37r[36;1H[94m~                                                                                                                                    [m[37;116H[K[37;116H5,1[11CAll[5;1H[?25h[?25l[37;106Hd[5;1H[?25h[?25l[37;107Hd[5;1H[37;106H  [5;1H[5;36r[36;1H
[1;37r[36;1H[94m~                                                                                                                                    [m[37;116H[K[37;116H5,0-1[9CAll[5;1H[?25h[?25l[37;106Hd[5;1H[?25h[?25l[37;107Hd[5;1H[37;106H  [5;1H[5;36r[36;1H
[1;37r[36;1H[94m~                                                                                                                                    [m[37;116H[K[37;116H5,1[11CAll[5;1H[?25h[?25l[37;106Hd[5;1H[?25h[?25l[37;107Hd[5;1H[37;106H  [5;1H[5;36r[36;1H
[1;37r[36;1H[94m~                                                                                                                                    [m[37;116H[K[37;116H5,1[11CAll[5;1H[?25h[?25l[37;106Hd[5;1H[?25h[?25l[37;107Hd[5;1H[37;106H  [5;3H[5;36r[36;1H
[1;37r[8;1H[97m[101mdone[m[36;1H[94m~                                                                                                                                    [m[37;116H[K[37;116H5,3[11CAll[5;3H[?25h[?25l[37;106Hd[5;3H[?25h[?25l[37;107Hd[5;3H[37;106H  [5;5H[5;36r[36;1H
[1;37r[5;13H[35m-f[m
  [97m[101mfi[m[36;1H[94m~                                                                                                                                    [m[37;116H[K[37;116H5,5[11CAll[5;5H[?25h[?25l[37;106Hd[5;5H[?25h[?25l[37;107Hd[5;5H[37;106H  [5;3H[5;36r[36;1H
[1;37r[36;1H[94m~                                                                                                                                    [m[37;116H[K[37;116H5,3[11CAll[5;3H[?25h[?25l[37;106Hd[5;3H[?25h[?25l[37;107Hd[5;3H[37;106H  [5;1H[5;36r[36;1H
[1;37r[36;1H[94m~                                                                                                                                    [m[37;116H[K[37;116H5,1[11CAll[5;1H[?25h[?25l[37;106Hd[5;1H[?25h[?25l[37;107Hd[5;1H[37;106H  [5;1H[5;36r[36;1H
[1;37r[36;1H[94m~                                                                                                                                    [m[37;116H[K[37;116H5,0-1[9CAll[5;1H[?25h[?25l[37;106Hd[5;1H[?25h[?25l[37;107Hd[5;1H[37;106H  [5;1H[5;36r[36;1H
[1;37r[36;1H[94m~                                                                                                                                    [m[37;116H[K[37;116H5,1[11CAll[5;1H[?25h[?25l[37;106Hd[5;1H[?25h[?25l[37;107Hd[5;1H[37;106H  [5;1H[5;36r[36;1H
[1;37r[36;1H[94m~                                                                                                                                    [m[37;116H[K[37;116H5,1[11CAll[5;1H[?25h[?25l[37;106Hd[5;1H[?25h[?25l[37;107Hd[5;1H[37;106H  [5;1H[5;36r[36;1H
[1;37r[36;1H[94m~                                                                                                                                    [m[37;116H[K[37;116H5,0-1[9CAll[5;1H[?25h[?25l[37;106Hd[5;1H[?25h[?25l[37;107Hd[5;1H[37;106H  [5;1H[5;36r[36;1H
[1;37r[36;1H[94m~                                                                                                                                    [m[37;116H[K[37;116H5,1[11CAll[5;1H[?25h[?25l[37;106Hd[5;1H[?25h[?25l[37;107Hd[5;1H[37;106H  [5;1H[5;36r[36;1H
[1;37r[36;1H[94m~                                                                                                                                    [m[37;116H[K[37;116H5,1[11CAll[5;1H[?25h[?25l[37;106Hd[5;1H[?25h[?25l[37;107Hd[5;1H[37;106H  [5;1H[5;36r[36;1H
[1;37r[36;1H[94m~                                                                                                                                    [m[37;116H[K[37;116H5,0-1[9CAll[5;1H[?25h[?25l[37;106Hd[5;1H[?25h[?25l[37;107Hd[5;1H[37;106H  [5;1H[5;36r[36;1H
[1;37r[36;1H[94m~                                                                                                                                    [m[37;116H[K[37;116H5,1[11CAll[5;1H[?25h[?25l[37;106Hd[5;1H[?25h[?25l[37;107Hd[5;1H[37;106H  [5;1H[5;36r[36;1H
[1;37r[36;1H[94m~                                                                                                                                    [m[37;116H[K[37;116H5,1[11CAll[5;1H[?25h[?25l[37;106Hd[5;1H[?25h[?25l[37;107Hd[5;1H[37;106H  [5;1H[5;36r[36;1H
[1;37r[36;1H[94m~                                                                                                                                    [m[37;116H[K[37;116H5,0-1[9CAll[5;1H[?25h[?25l[37;106Hd[5;1H[?25h[?25l[37;107Hd[5;1H[37;106H  [5;1H[5;36r[36;1H
[1;37r[36;1H[94m~                                                                                                                                    [m[37;116H[K[37;116H5,1[11CAll[5;1H[?25h[?25l[37;106Hd[5;1H[?25h[?25l[37;107Hd[5;1H[37;106H  [5;1H[5;36r[36;1H
[1;37r[36;1H[94m~                                                                                                                                    [m[37;116H[K[37;116H5,0-1[9CAll[5;1H[?25h[?25l[37;106Hd[5;1H[?25h[?25l[37;107Hd[5;1H[37;106H  [4;1H
[94m~                                                                                                                                    [m[37;116H4,1  [4;1H[?25h[?25l[37;106Hd[4;1H[?25h[?25l[37;107Hd[4;1H[37;106H  [3;1H
[94m~                                                                                                                                    [m[37;116H3[3;1H[?25h[?25l[37;106Hd[3;1H[?25h[?25l[37;107Hd[3;1H[37;106H  [2;1H
[94m~                                                                                                                                    [m[37;116H2,0-1[2;1H[?25h[?25l[37;106Hd[2;1H[?25h[?25l[37;107Hd[2;1H[37;106H  [1;1H
[94m~                                                                                                                                    [m[37;116H1,1  [1;1H[?25h[?25l[37;106Hd[1;1H[?25h[?25l[37;106H [1;1H[1;1H[K[37;1H--No lines in buffer--[37;116H[K[37;116H0,0-1[9CAll[1;1H[?25h[?25l[37;106Hd[1;1H[?25h[?25l[37;107Hd[1;1H[37;106H  [1;1H[?25h[?25l[37;106Hd[1;1H[?25h[?25l[37;107Hd[1;1H[37;106H  [1;1H[?25h[?25l[37;106Hi[1;1H[37;106H [1;1H[37;1H[1m-- INSERT --[m[37;13H[K[37;116H0,1[11CAll[1;1H[?25h[?25li[37;116H1,2[1;2H[?25h[?25l#!/bin/bash[2;1H[K[3;1H[34m# Variables[m[3;12H[K[4;1H[36mDATE[m=[35m$([m[35mdate +[m[38;5;130m"[m[31m%Y-%m-%d_%H[m[4;26H[K[4;26H[?25h[?25l[31m-%M-%S[m[38;5;130m"[m[35m)[m
[36mNEW_FOLDER[m=[38;5;130m"[m[31m/etc/records-new[m[38;5;130m"[m[5;30H[K[6;1H[36mBUCKET_NAME[m=[38;5;130m"[m[31mnitrol[m[6;20H[K[6;20H[?25h[?25l[31mogbucket[m[38;5;130m"[m
[36mDESTINATION[m=[38;5;130m"[m[31mgs://[m[35m$BUCKET_NAME[m[31m/[m[35m$DATE[m[31m/[m[38;5;130m"[m[7;39H[K[8;1HSERVICE_ACC[8;12H[K[8;12H[?25h[?25l[36mSERVICE_ACCOUNT_KEY[m=[38;5;130m"[m[31m/home/ubuntu/bin/service.json[m[38;5;130m"[m[9;1H[K[10;1H[34m# Create a new fold[m[10;20H[K[10;20H[?25h[?25l[34mer wi[?25h[?25lth the current date and time[m
sudo [38;5;130mmkdir[m [35m-p[m [35m$NEW_FOLDER[m[11;26H[K[12;1H[K[13;1H[34m# Co[m[13;5H[K[13;5H[?25h[?25l[34mpy log file data to the new folder[m
sudo cp [35m-r[m /etc/records/ $[14;27H[K[14;27H[?25h[?25l[35m$NEW_FOLDER[m/[15;1H[K[16;1H[34m# Get the latest two files in the log folder[m[16;45H[K[17;1H LA[17;4H[K[17;4H[?25h[?25l[36mLATEST_FILES[m=[35m$([m[35msudo [m[38;5;130mls[m[35m -1t /etc/records/[m[35m$whoami_[m[35m* [m[38;5;130m|[m[35m head -n [m[31m2[m[35m)[m[18;1H[K[19;1H[K[19;1H[?25h[?25l[34m# Extract filenames to keep[m
[36mFILES_TO_KEEP[m=[35m$([m[38;5;130mecho[m[31m [m[35m$LATEST_FILES[m[20;35H[K[20;35H[?25h[?25l[31m [m[38;5;130m|[m[35m xargs -n [m[31m1[m[35m basename [m[38;5;130m|[m[35m tr [m[38;5;130m'[m[31m\n[m[38;5;130m'[m[35m [m[38;5;130m'[m[31m [m[38;5;130m'[m[35m)[m[21;1H[K[22;1H[34m# Remove all files excep[m[22;25H[K[22;25H[?25h[?25l[34mt the latest two[m
[38;5;130mfor[m FILE [38;5;130min[m [35m$([m[35msudo [m[38;5;130mls[m[35m /etc/records[m[35m)[m; [38;5;130mdo[m   [23;43H[K[24;1H   [24;4H[K[24;4H[?25h[?25l [38;5;130mif ![m [38;5;130mecho[m[31m [m[35m$FILES_TO_KEEP[m[31m [m[38;5;130m|[m [38;5;130mgrep[m [35m-qw[m [35m$FILE[m[38;5;130m;[m [38;5;130mthen[m
        s[25;10H[K[25;10H[?25h[?25ludo [38;5;130mrm[m [38;5;130m-f[m /etc/records/[35m$FILE[m[38;5;130m;[m
    [38;5;130mfi;[m [26;9H[K[27;1H[38;5;130mdone[m[27;5H[K[28;1H[K[29;1H[34m# Authenticate [m[29;16H[K[29;16H[?25h[?25l[34mwith GCP[m
gcloud auth activate-service-account [35m--key-file=[m[38;5;130m"[m[35m$SERV[m[30;55H[K[30;55H[?25h[?25l[35mICE_ACCOUNT_KEY[m[38;5;130m"[m[31;1H[K[32;1H[34m# Upload the new folder to GCP bucket[m[32;38H[K[33;1Hsudo gs[33;8H[K[33;8H[?25h[?25lutil cp [35m-r[m [35m$NEW_FOLDER[m [35m$DESTINATION[m[34;1H[K[35;1H[34m# Optionally, remove the l[m[35;27H[K[35;27H[?25h[?25l[34mocal copy after upload[m
sudo [38;5;130mrm[m [35m-rf[m [35m$NEW_FOLDER[m[36;24H[K[1;36r[1;1H[2M[1;37r[36;1H[38;5;130mecho[m[31m [m[38;5;130m"[m[31mLog file [m[37;11H[1m(paste) --[m[37;116H[K[36;16H[?25h[?25l[31muploaded and original file cleared, except for the latest two f[?25h[?25l[1;36r[m[36;1H
[1;37r[35;79H[31miles.[m[38;5;130m"[m[37;11H[1m--a[m[37;13H[K[37;116H39,1[10CBot[36;1H[?25h[37;1H[K[36;1H[?25l[37;106H^[[36;1H[37;106H  [36;1H[37;116H39,0-1[8CBot[36;1H[?25h[?25l[37;106H:[36;1H[37;106H[K[37;1H:[?2004h[?25hwq[?25l[?2004l"recordslog.sh" 39L, 1116C written[23;2t[23;1t
[?2004l[?1l>[?25h[>4;m[?1049l[23;0;0t]0;ubuntu@bastion: ~/bin[01;32mubuntu@bastion[00m:[01;34m~/bin[00m$ exit
exit

Script done on 2024-08-07 11:48:49+00:00 [COMMAND_EXIT_CODE="0"]
